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.
Net::IMP::Pattern
new_factory
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.
rx
rxlen
/\d+/
/\d{1,10}/
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.
/\d*/
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.
string
The following actions are supported
Causes a deny (e.g. close) of the connection, with the deny message specified in actdata
actdata
Rejects the data, e.g. replaces the data with '' and sends the string given in actdata back to the sender.
''
Replaces the data with the string given in actdata
Meaning depends on action. See there.
action
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.
To install Net::IMP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::IMP
CPAN shell
perl -MCPAN -e shell install Net::IMP
For more information on module installation, please visit the detailed CPAN module installation guide.