Net::IMP::Pattern(3p)

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 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.

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 with "rxlen", a fixed string can be given.

rxdir 0|1
    With this optional argument one can restrict the direction where "rx" or "string" will be applied. Data in the other direction will pass directly.

action String
    The following actions are supported

    'deny'
        Causes a deny (e.g. close) of the connection, with the deny message specified in "actdata"

    'reject'
        Rejects the data, e.g. replaces the data with '' and sends the string given in "actdata" back to the sender.

    'replace'
        Replaces the data with the string given in "actdata"

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.