{
    "mode": "perldoc",
    "parameter": "Web::Scraper::Filter",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Web%3A%3AScraper%3A%3AFilter/json",
    "generated": "2026-06-16T06:23:52Z",
    "synopsis": "package Web::Scraper::Filter::YAML;\nuse base qw( Web::Scraper::Filter );\nuse YAML ();\nsub filter {\nmy($self, $value) = @;\nYAML::Load($value);\n}\n1;\nuse Web::Scraper;\nmy $scraper = scraper {\nprocess \".yaml-code\", data => [ 'TEXT', 'YAML' ];\n};",
    "sections": {
        "NAME": {
            "content": "Web::Scraper::Filter - Base class for Web::Scraper filters\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "package Web::Scraper::Filter::YAML;\nuse base qw( Web::Scraper::Filter );\nuse YAML ();\n\nsub filter {\nmy($self, $value) = @;\nYAML::Load($value);\n}\n\n1;\n\nuse Web::Scraper;\n\nmy $scraper = scraper {\nprocess \".yaml-code\", data => [ 'TEXT', 'YAML' ];\n};\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Web::Scraper::Filter is a base class for text filters in Web::Scraper. You can create your own\ntext filter by subclassing this module.\n\nThere are two ways to create and use your custom filter. If you name your filter\nWeb::Scraper::Filter::Something, you just call:\n\nprocess $exp, $key => [ 'TEXT', 'Something' ];\n\nIf you declare your filter under your own namespace, like 'MyApp::Filter::Foo',\n\nprocess $exp, $key => [ 'TEXT', '+MyApp::Filter::Foo' ];\n\nYou can also inline your filter function or regexp without creating a filter class:\n\nprocess $exp, $key => [ 'TEXT', sub { s/foo/bar/ } ];\n\nprocess $exp, $key => [ 'TEXT', qr/Price: (\\d+)/ ];\nprocess $exp, $key => [ 'TEXT', qr/(?<name>\\w+): (?<value>\\w+)/ ];\n\nNote that this function munges $ and returns the count of replacement. Filter code special\ncases if the return value of the callback is number and $ value is updated.\n\nYou can, of course, stack filters like:\n\nprocess $exp, $key => [ '@href', 'Foo', '+MyApp::Filter::Bar', \\&baz ];\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Tatsuhiko Miyagawa\n",
            "subsections": []
        }
    },
    "summary": "Web::Scraper::Filter - Base class for Web::Scraper filters",
    "flags": [],
    "examples": [],
    "see_also": []
}