1Path::Dispatcher::MatchU(s3eprm)Contributed Perl DocumenPtaatthi:o:nDispatcher::Match(3pm)
2
3
4

NAME

6       Path::Dispatcher::Match - the result of a successful rule match
7

VERSION

9       version 1.08
10

SYNOPSIS

12           my $rule = Path::Dispatcher::Rule::Tokens->new(
13               tokens => [ 'attack', qr/^\w+$/ ],
14               block  => sub {
15                   my $match = shift;
16                   attack($match->pos(2))
17               },
18           );
19
20           my $match = $rule->match("attack dragon");
21
22           # introspection
23           $match->path                # "attack dragon"
24           $match->leftover            # empty string (populated with prefix rules)
25           $match->rule                # $rule
26           $match->positional_captures # ["attack", "dragon"] (decided by the rule)
27           $match->pos(1)              # "attack"
28           $match->pos(2)              # "dragon"
29
30           $match->run                 # attack("dragon")
31

DESCRIPTION

33       If a Path::Dispatcher::Rule successfully matches a path, it creates one
34       or more "Path::Dispatcher::Match" objects.
35

ATTRIBUTES

37   rule
38       The Path::Dispatcher::Rule that created this match.
39
40   path
41       The path that the rule matched.
42
43   leftover
44       The rest of the path. This is populated when the rule matches a prefix
45       of the path.
46
47   positional_captures
48       Any positional captures generated by the rule. For example,
49       Path::Dispatcher::Rule::Regex populates this with the capture
50       variables.
51
52   named_captures
53       Any named captures generated by the rule. For example,
54       Path::Dispatcher::Rule::Regex populates this with named captures.
55
56   parent
57       The parent match object, if applicable (which may be set if this match
58       is the child of, for exampl, a Path::Dispatcher::Rule::Under prefix)
59

METHODS

61   run
62       Executes the rule's codeblock with the same arguments.
63
64   pos($i)
65       Returns the $ith positional capture, 1-indexed.
66

SUPPORT

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

AUTHOR

74       Shawn M Moore, "<sartak at bestpractical.com>"
75
77       This software is copyright (c) 2020 by Shawn M Moore.
78
79       This is free software; you can redistribute it and/or modify it under
80       the same terms as the Perl 5 programming language system itself.
81
82
83
84perl v5.36.0                      2023-01-20      Path::Dispatcher::Match(3pm)
Impressum