Help-Site Computer Manuals
Software
Hardware
Programming
Networking
  Algorithms & Data Structures   Programming Languages   Revision Control
  Protocols
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

Hook::Filter::Rule
A hook filter rule

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


NAME

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


DESCRIPTION

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


SYNOPSIS


    use Hook::Filter::Rule;

    my $rule = Hook::Filter::Rule->new("1");

    if ($rule->eval) {

        print "just now, the rule [".$rule->rule."] is true\n";

    }


INTERFACE

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

$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()).

$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().

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


DIAGNOSTICS

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.


BUGS AND LIMITATIONS

See Hook::Filter


SEE ALSO

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


VERSION

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


AUTHOR

Erwan Lemonnier <erwan@cpan.org>


LICENSE

See Hook::Filter.

Programminig
Wy
Wy
yW
Wy
Programming
Wy
Wy
Wy
Wy