GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Path::Dispatcher::Rule::Tokens(3) User Contributed Perl Documentation Path::Dispatcher::Rule::Tokens(3)

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

version 1.08

    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");

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

Each token can be a literal string, a regular expression, or a list of either (which are taken to mean alternations). For example, the tokens:

    [ 'ticket', [ 'show', 'display' ], [ qr/^\d+$/, qr/^#\w{3}/ ] ]

first matches "ticket". Then, the next token must be "show" or "display". The final token must be a number or a pound sign followed by three word characters.

The results are the tokens in the original string, as they were matched. If you have three tokens, then "match->pos(1)" will be the string's first token ("ticket"), "match->pos(2)" its second ("display"), and "match->pos(3)" its third ("#AAA").

Capture groups inside a regex token are completely ignored.

A string that is used to tokenize the path. The delimiter must be a string because prefix matches use "join" on unmatched tokens to return the leftover path. In the future this may be extended to support having a regex delimiter.

The default is a space, but if you're matching URLs you probably want to change this to a slash.

Decide whether the rule matching is case sensitive. Default is 1, case sensitive matching.

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

Shawn M Moore, "<sartak at bestpractical.com>"

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.

2020-07-12 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.