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::.
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::.
Hook::Filter::Rule
$rule
$r->eval()
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()).
source()
$r->source($message)
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().
$message
eval()
$r->rule()
Return the rule's string ($rule in new()).
new()
The following functions are exported by the default plugin library Hook::Filter::Plugin::Library:
subname
arg
from
use Hook::Filter::Rule
Hook::Filter::Rule->new($rule)
$rule->eval()
$rule->source($text)
$text
See Hook::Filter
See Hook::Filter, Hook::Filter::RulePool, Hook::Filter::Hooker, Hook::Filter::Plugins::Library.
$Id: Rule.pm,v 1.7 2008/06/09 21:04:08 erwan_lemonnier Exp $
Erwan Lemonnier <erwan@cpan.org>
<erwan@cpan.org>
See Hook::Filter.
To install Hook::Filter, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Hook::Filter
CPAN shell
perl -MCPAN -e shell install Hook::Filter
For more information on module installation, please visit the detailed CPAN module installation guide.