Path::...Tokens(3pm)
β¨ Path::Dispatcher::Rule::Tokens β the whole vibe π
okay so bestie, this is a page from the User Contributed Perl Documentation set, and it's literally about Path::Dispatcher::Rule::Tokens(3pm) β a rule where the predicate is a list of tokens. π
πΈ VERSION πΈ
version 1.08 β yes queen, that's the one β¨
π¦ SYNOPSIS π¦
my $rule = Path::Dispatcher::Rule::Tokens->new(
tokens => [ "comment", "show", qr/^\d+$/ ],
delimiter => '/',
block => sub { display_comment(shift->pos(3)) },
);
$rule->match("/comment/show/25");
look at her go π«Ά
π DESCRIPTION π
Rules in this class match a path by using a list of tokens. that's it, that's the whole thing, it's giving simple and iconic π
π ATTRIBUTES π
π tokens
Every single token can be:
- a literal string,
- a regular expression, or
- a list of either β and ngl, a list means alternations π«
so like, for example, these tokens:
[ 'ticket', [ 'show', 'display' ], [ qr/^\d+$/, qr/^#\w{3}/ ] ]
first it matches ticket. then the next token has to be show or display. and the final token has to be a number or a pound sign followed by three word characters. slay π
the results are the tokens in the original string, exactly as they were matched. so if you have three tokens, then match->pos(1) gives you the string's first token (ticket), match->pos(2) gives you its second (display), and match->pos(3) gives you its third (#AAA). fr fr, the positions are just the tokens as they came π
capture groups inside a regex token are completely ignored. like, fully ignored, don't even try it bestie π
π§ delimiter
A string that's used to tokenize the path. and it must be a string, because prefix matches use join on unmatched tokens to hand back the leftover path. in the future this may be extended to support having a regex delimiter, but rn? string only, no cap.
The default is a space, but if you're matching URLs you probably wanna change it to a slash πΈ
β case_sensitive
Decides whether the rule matching is case sensitive or not. Default is 1, which means case sensitive matching β¨
π SUPPORT π
Bugs may be submitted through the RT bug tracker β https://rt.cpan.org/Public/Dist/Display.html?Name=Path-Dispatcher β or you can email bug-Path-Dispatcher@rt.cpan.org. please be nice, it's giving feedback loop energy π«Ά
π 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. π
and that's a wrap bestie π this was documented with perl v5.30.3, dated 2020-07-13, and yeah β the page title says it's Path::...Tokens(3pm) but you and me both know it's really Path::Dispatcher::Rule::Tokens, iykyk π
β¨ go forth and tokenize, main character π¦
π¦ 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