# phpman > perldoc > Web::Scraper::Filter

## NAME
    [Web::Scraper::Filter](https://www.chedong.com/phpMan.php/perldoc/Web%3A%3AScraper%3A%3AFilter/markdown) - Base class for [Web::Scraper](https://www.chedong.com/phpMan.php/perldoc/Web%3A%3AScraper/markdown) filters

## SYNOPSIS
      package [Web::Scraper::Filter::YAML](https://www.chedong.com/phpMan.php/perldoc/Web%3A%3AScraper%3A%3AFilter%3A%3AYAML/markdown);
      use base qw( [Web::Scraper::Filter](https://www.chedong.com/phpMan.php/perldoc/Web%3A%3AScraper%3A%3AFilter/markdown) );
      use YAML ();

      sub filter {
          my($self, $value) = @_;
          [YAML::Load](https://www.chedong.com/phpMan.php/perldoc/YAML%3A%3ALoad/markdown)($value);
      }

      1;

      use [Web::Scraper](https://www.chedong.com/phpMan.php/perldoc/Web%3A%3AScraper/markdown);

      my $scraper = scraper {
          process ".yaml-code", data => [ 'TEXT', 'YAML' ];
      };

## DESCRIPTION
    [Web::Scraper::Filter](https://www.chedong.com/phpMan.php/perldoc/Web%3A%3AScraper%3A%3AFilter/markdown) is a base class for text filters in [Web::Scraper](https://www.chedong.com/phpMan.php/perldoc/Web%3A%3AScraper/markdown). You can create your own
    text filter by subclassing this module.

    There are two ways to create and use your custom filter. If you name your filter
    [Web::Scraper::Filter::Something](https://www.chedong.com/phpMan.php/perldoc/Web%3A%3AScraper%3A%3AFilter%3A%3ASomething/markdown), you just call:

      process $exp, $key => [ 'TEXT', 'Something' ];

    If you declare your filter under your own namespace, like '[MyApp::Filter::Foo](https://www.chedong.com/phpMan.php/perldoc/MyApp%3A%3AFilter%3A%3AFoo/markdown)',

      process $exp, $key => [ 'TEXT', '+[MyApp::Filter::Foo](https://www.chedong.com/phpMan.php/perldoc/MyApp%3A%3AFilter%3A%3AFoo/markdown)' ];

    You can also inline your filter function or regexp without creating a filter class:

      process $exp, $key => [ 'TEXT', sub { s/foo/bar/ } ];

      process $exp, $key => [ 'TEXT', qr/Price: (\d+)/ ];
      process $exp, $key => [ 'TEXT', qr/(?<name>\w+): (?<value>\w+)/ ];

    Note that this function munges $_ and returns the count of replacement. Filter code special
    cases if the return value of the callback is number and $_ value is updated.

    You can, of course, stack filters like:

      process $exp, $key => [ '@href', 'Foo', '+[MyApp::Filter::Bar](https://www.chedong.com/phpMan.php/perldoc/MyApp%3A%3AFilter%3A%3ABar/markdown)', \&baz ];

## AUTHOR
    Tatsuhiko Miyagawa

