Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
Path::Dispatcher::RuleUser Contributed Perl DocumentaPath::Dispatcher::Rule(3)

NAME
       Path::Dispatcher::Rule -	predicate and codeblock

VERSION
       version 1.08

SYNOPSIS
	   my $rule = Path::Dispatcher::Rule::Regex->new(
	       regex =>	qr/^quit/,
	       block =>	sub { die "Program terminated by user.\n" },
	   );

	   $rule->match("die");	# undef, because "die" !~ /^quit/

	   my $match = $rule->match("quit"); # creates a Path::Dispatcher::Match

	   $match->run;	# exits	the program

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

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

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

SUPPORT
       Bugs may	be submitted through the RT bug	tracker
       <https://rt.cpan.org/Public/Dist/Display.html?Name=Path-Dispatcher> (or
       bug-Path-Dispatcher@rt.cpan.org <mailto:bug-Path-
       Dispatcher@rt.cpan.org>).

AUTHOR
       Shawn M Moore, "<sartak at bestpractical.com>"

COPYRIGHT AND LICENSE
       This software is	copyright (c) 2020 by Shawn M Moore.

       This is free software; you can redistribute it and/or modify it under
       the same	terms as the Perl 5 programming	language system	itself.

perl v5.32.0			  2020-07-12	     Path::Dispatcher::Rule(3)

NAME | VERSION | SYNOPSIS | DESCRIPTION | ATTRIBUTES | METHODS | SUPPORT | AUTHOR | COPYRIGHT AND LICENSE

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=Path::Dispatcher::Rule&sektion=3&manpath=FreeBSD+12.2-RELEASE+and+Ports>

home | help