Path::...CodeRef(3pm)
π Path::Dispatcher::Rule::CodeRef (3pm)
okay bestie, so this is a page from the User Contributed Perl Documentation (the 3pm kind, you know the vibe), and it's about a module called Path::Dispatcher::Rule::CodeRef π
β¨ NAME β¨
Path::Dispatcher::Rule::CodeRef β the predicate is literally any subroutine. like, any one. your imagination is the limit, no cap π
πΈ VERSION πΈ
version 1.08 β she's serving exactly this version, don't @ me β¨
π¦ SYNOPSIS π¦
my $rule = Path::Dispatcher::Rule::CodeRef->new(
matcher => sub { time % 2 },
block => sub { warn "Odd time!" },
);
my $undef = $rule->match("foo"); # even time; no match :)
my $match = $rule->match("foo"); # odd time; creates a Path::Dispatcher::Match
$rule->run; # warns "Odd time!"
so yes, that matcher is just vibing on time % 2 and the whole rule is basically a coin flip. iconic behavior honestly π
π DESCRIPTION π
Rules in this class can match arbitrarily complex values. the way that they can match literally anythingβ¦ main character energy fr fr π
BUT β and this is the important part, listen up β you should only reach for this when there is no other recourse, because there's no way we can inspect how things match. like, the module literally cannot see inside your little coderef and figure out what's going on. it's giving mystery box π¦
You're much better off creating a custom subclass of Path::Dispatcher::Rule if that's at all possible. do that instead, bestie, please π
π ATTRIBUTES π
π matcher
A coderef that returns undef if there's no match β otherwise it returns a list of strings (the results). so: no match β undef, match β list of strings. simple as π«Ά
The coderef receives the path object as its argument, and the path string as $_. both at once, she's flexible like that β¨
π§ SUPPORT π§
Found a bug? π Same. Bugs may be submitted through the RT bug tracker:
https://rt.cpan.org/Public/Dist/Display.html?Name=Path-Dispatcher
(or, if email is more your vibe, hit up bug-Path-Dispatcher@rt.cpan.org π)
π AUTHOR π
Shawn M Moore, "sartak at bestpractical.com" β shoutout to the author, we love a legend π«‘β
πΈ 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. slay, open source queen π
okay and for the lil' sign-off: this gorgeous page was rendered by perl v5.30.3 on 2020-07-13, under the Path::...CodeRef(3pm) manual name. that's the whole thing bestie, go write a custom subclass instead of using this rule, mwah π
β¨π
π¦ 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