NAME
Net::IMP::Pattern - IMP plugin for reacting to matched pattern
SYNOPSIS
my $factory = Net::IMP::Pattern->new_factory(
rx => qr/this|that/, # pattern
rxlen => 7, # maximum length regex can match
action => 'replace', # 'deny','reject'..
actdata => 'newdata', # replace with newdata
);
DESCRIPTION
Net::IMP::Pattern
implements an analyzer to match regular expressions and replace or reject the data or cause a deny. The behavior is specified in the arguments given to new_factory
or new_analyzer
.
- rx Regex
-
The regular expression (as Regexp).
rx
should only match up to the number of bytes specified byrxlen
, e.g. regular expressions like/\d+/
should be avoided, better use/\d{1,10}/
. Although it will do its best to only matchrxlen
in that case, these kind of broad regular expressions are a sign, that the user does not really know what should be matched.Regular expressions which can match the empty buffer, like
/\d*/
, are not allowed at all and it will croak when trying to use such a regular expression. - rxlen Integer
-
The maximum number of bytes the regex could match or is allowed to match. This argument is necessary together with
rx
because there is no way to determine how many bytes an arbitrary regular expression might match. - string String
-
Instead of giving the regular expression
rx
together withrxlen
, a fixed string can be given. - rxdir 0|1
-
With this optional argument one can restrict the direction where
rx
orstring
will be applied. Data in the other direction will pass directly. - action String
-
The following actions are supported
- actdata String
-
Meaning depends on
action
. See there.
AUTHOR
Steffen Ullrich <sullr@cpan.org>
COPYRIGHT
Copyright by Steffen Ullrich.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.