Net::IMP::Pattern - IMP plugin for reacting to matched pattern
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 );
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
.
The regular expression (as Regexp).
rx
should only match up to the number of bytes specified by rxlen
, e.g. regular expressions like /\d+/
should be avoided, better use /\d{1,10}/
. Although it will do its best to only match rxlen
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.
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.
Instead of giving the regular expression rx
together with rxlen
, a fixed string can be given.
With this optional argument one can restrict the direction where rx
or string
will be applied. Data in the other direction will pass directly.
The following actions are supported
Meaning depends on action
. See there.
Steffen Ullrich <sullr@cpan.org>
Copyright by Steffen Ullrich.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.