1Path::Dispatcher::Rule:U:sTeorkeCnosn(t3rpimb)uted PerlPDaotchu:m:eDnitsaptaitocnher::Rule::Tokens(3pm)
2
3
4

NAME

6       Path::Dispatcher::Rule::Tokens - predicate is a list of tokens
7

VERSION

9       version 1.08
10

SYNOPSIS

12           my $rule = Path::Dispatcher::Rule::Tokens->new(
13               tokens    => [ "comment", "show", qr/^\d+$/ ],
14               delimiter => '/',
15               block     => sub { display_comment(shift->pos(3)) },
16           );
17
18           $rule->match("/comment/show/25");
19

DESCRIPTION

21       Rules of this class use a list of tokens to match the path.
22

ATTRIBUTES

24   tokens
25       Each token can be a literal string, a regular expression, or a list of
26       either (which are taken to mean alternations). For example, the tokens:
27
28           [ 'ticket', [ 'show', 'display' ], [ qr/^\d+$/, qr/^#\w{3}/ ] ]
29
30       first matches "ticket". Then, the next token must be "show" or
31       "display". The final token must be a number or a pound sign followed by
32       three word characters.
33
34       The results are the tokens in the original string, as they were
35       matched. If you have three tokens, then "match->pos(1)" will be the
36       string's first token ("ticket"), "match->pos(2)" its second
37       ("display"), and "match->pos(3)" its third ("#AAA").
38
39       Capture groups inside a regex token are completely ignored.
40
41   delimiter
42       A string that is used to tokenize the path. The delimiter must be a
43       string because prefix matches use "join" on unmatched tokens to return
44       the leftover path. In the future this may be extended to support having
45       a regex delimiter.
46
47       The default is a space, but if you're matching URLs you probably want
48       to change this to a slash.
49
50   case_sensitive
51       Decide whether the rule matching is case sensitive. Default is 1, case
52       sensitive matching.
53

SUPPORT

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

AUTHOR

61       Shawn M Moore, "<sartak at bestpractical.com>"
62
64       This software is copyright (c) 2020 by Shawn M Moore.
65
66       This is free software; you can redistribute it and/or modify it under
67       the same terms as the Perl 5 programming language system itself.
68
69
70
71perl v5.38.0                      2023-07-21Path::Dispatcher::Rule::Tokens(3pm)
Impressum