Hook::Filter::Rule - A hook filter rule


A filter rule is a string containing a perl expression that evaluates to either true or false.

A rule may contain calls to functions exported by any module under Hook::Filter::Plugins::.


    use Hook::Filter::Rule;

    my $rule = Hook::Filter::Rule->new("1");
    if ($rule->eval) {
        print "just now, the rule [".$rule->rule."] is true\n";


my $r = new($rule)

Return a new Hook::Filter::Rule created from the string $rule. $rule is a valid line of perl code that should return either true or false when eval-ed. It can contain calls to any of the functions exported by the plugin modules located under Hook::Filter::Plugins::.


Eval this rule. Return 0 if the rule eval-ed to false. Return 1 if the rule eval-ed to true, or if the rule died/croaked.

If the rule dies/croaks/confesses while being eval-ed, a perl warning is thrown and the rule is assumed to return true (fail-safe). The warning contains details about the error message, the rule itself and where it comes from (as specified with source()).


Specify the origin of this rule. If the rule was parsed from a rule file, $message should be the path to this file. This is used in the warning message emitted when a rule dies during eval().


Return the rule's string ($rule in new()).


use Hook::Filter::Rule croaks if a plugin module tries to export a function name that is already exported by an other plugin.
Hook::Filter::Rule->new($rule) croaks if $rule is not a scalar.
$rule->eval() will emit a perl warning if the rule dies when eval-ed.
$rule->source($text) croaks if $text is not a scalar.


See Hook::Filter


See Hook::Filter, Hook::Filter::RulePool, Hook::Filter::Hooker, Hook::Filter::Plugins::Library.


$Id:,v 1.6 2007/05/24 14:52:37 erwan_lemonnier Exp $


Erwan Lemonnier <>


See Hook::Filter.