Query: path::dispatcher::rule
OS: debian
Section: 3pm
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
Path::Dispatcher::Rule(3pm) User Contributed Perl Documentation Path::Dispatcher::Rule(3pm)NAMEPath::Dispatcher::Rule - predicate and codeblockSYNOPSISmy $rule = Path::Dispatcher::Rule::Regex->new( regex => qr/^quit/, block => sub { die "Program terminated by user. " }, ); $rule->match("die"); # undef, because "die" !~ /^quit/ my $match = $rule->match("quit"); # creates a Path::Dispatcher::Match $match->run; # exits the programDESCRIPTIONA rule has a predicate and an optional codeblock. Rules can be matched (which checks the predicate against the path) and they can be ran (which invokes the codeblock). This class is not meant to be instantiated directly, because there is no predicate matching function. Instead use one of the subclasses such as Path::Dispatcher::Rule::Tokens.ATTRIBUTESblock An optional block of code to be run. Please use the "run" method instead of invoking this attribute directly. prefix A boolean indicating whether this rule can match a prefix of a path. If false, then the predicate must match the entire path. One use-case is that you may want a catch-all rule that matches anything beginning with the token "ticket". The unmatched, latter part of the path will be available in the match object.METHODSmatch path -> match Takes a path and returns a Path::Dispatcher::Match object if it matched the predicate, otherwise "undef". The match object contains information about the match, such as the results (e.g. for regex, a list of the captured variables), the "leftover" path if "prefix" matching was used, etc. run Runs the rule's codeblock. If none is present, it throws an exception. perl v5.12.4 2011-08-30 Path::Dispatcher::Rule(3pm)
Similar Topics in the Unix Linux Community |
---|
Regex?? Please help |
Path Environment |
regex - display all occurrences of match |
NAWK - looping with match() function |
Career Path |