Path::...::Match(3pm)
π Path::...::Match(3pm) β bestie's guide to the match object π
okay so this is the manual page for Path::Dispatcher::Match, which lives in User Contributed Perl Documentation land. It's giving "the result of a successful rule match" and honestly? it's iconic. Version 1.08, no cap. π
β¨ SYNOPSIS β¨
my $rule = Path::Dispatcher::Rule::Tokens->new(
tokens => [ 'attack', qr/^\w+$/ ],
block => sub {
my $match = shift;
attack($match->pos(2))
},
);
my $match = $rule->match("attack dragon");
# introspection
$match->path # "attack dragon"
$match->leftover # empty string (populated with prefix rules)
$match->rule # $rule
$match->positional_captures # ["attack", "dragon"] (decided by the rule)
$match->pos(1) # "attack"
$match->pos(2) # "dragon"
$match->run # attack("dragon")
like look at her. building a rule, matching "attack dragon", then just casually doing a lil introspection moment. and then run and suddenly we're attacking a dragon. main character energy fr fr. ππ₯
πΈ DESCRIPTION πΈ
so here's the tea: when a Path::Dispatcher::Rule successfully matches a path, it makes one or more "Path::Dispatcher::Match" objects. that's it. that's the whole vibe. it's the little trophy you get handed when your rule actually hits. π
π¦ ATTRIBUTES π¦
rule
the Path::Dispatcher::Rule that created this match. like, your match's origin story. its mother, if you will. π
path
the path that the rule matched. the whole entire thing.
leftover
the rest of the path. this one gets populated when the rule matches a prefix of the path β so like, the crumbs left on the plate after the rule took its bite. π
positional_captures
any positional captures that the rule generated. for example, Path::Dispatcher::Rule::Regex fills this up with the capture variables. so if your rule's out here capturing stuff, this is where it all lands.
named_captures
any named captures that the rule generated. for example, Path::Dispatcher::Rule::Regex fills this up with named captures. same energy as above, but with names attached. β¨
parent
the parent match object, if that's applicable β which it might be if this match is the child of, like, a Path::Dispatcher::Rule::Under prefix. family tree moment. π§
π METHODS π
run
executes the rule's codeblock with the same arguments. go time. hit it.
pos($i)
returns the *$i*th positional capture, 1-indexed. so pos(1) is the first one, not the zeroth. bestie, please remember this, it's the classic off-by-one trap and it will humble you. π
π«Ά SUPPORT π«Ά
found a bug? (rude of it.) bugs may be submitted through the RT bug tracker:
<https://rt.cpan.org/Public/Dist/Display.html?Name=Path-Dispatcher>
or you can email it in at bug-Path-Dispatcher@rt.cpan.org. either way, they got you. π
β AUTHOR β
Shawn M Moore, "<sartak at bestpractical.com>". king behavior, honestly. π
π 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.
periodt. legal but make it cute.
and that's the whole page, bestie β perl v5.30.3, dated 2020-07-13, which is literally the footer energy we're signing off with. go forth and match some paths. πβ¨π
π¦ where this page comes from
- debian bookworm: libpath-dispatcher-perl 1.08-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libpath-dispatcher-perl 1.08-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libpath-dispatcher-perl 1.08-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libpath-dispatcher-perl 1.08-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libpath-dispatcher-perl 1.08-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libpath-dispatcher-perl 1.08-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms