Michael Peters > CGI-Application-Dispatch > CGI::Application::Dispatch::Regexp

Download:
CGI-Application-Dispatch-2.12.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  1
Stalled  1
View/Report Bugs
Source   Latest Release: CGI-Application-Dispatch-3.12

NAME ^

CGI::Application::Dispatch::Regexp - Dispatch requests to CGI::Application based objects using regular expressions

SYNOPSIS ^

    use CGI::Application::Dispatch::Regexp;

    CGI::Application::Dispatch::Regexp->dispatch(
            prefix  => 'MyApp',
            table   => [
                ''                                    => { app => 'Welcome', rm => 'start' },
                qr|/([^/]+)/?|                        => { names => ['app']                },
                qr|/([^/]+)/([^/]+)/?|                => { names => [qw(app rm)]           },
                qr|/([^/]+)/([^/]+)/page(\d+)\.html?| => { names => [qw(app rm page)]      },
            ],
    );

DESCRIPTION ^

CGI::Application::Dispatch uses its own syntax dispatch table. CGI::Application::Dispatch::Regexp allows to use flexible and powerful Perl regular expressions to transform PATH_INFO into argument list.

DISPATCH TABLE ^

The dispatch table should contain list of regular expressions with hashref of corresponding parameters. Hash element 'names' is a list of names of regular expression groups. The default table looks like this:

        table       => [
            qr|/([^/]+)/?|          => { names => ['app']      },
            qr|/([^/]+)/([^/]+)/?|  => { names => [qw(app rm)] },
        ],

Here's an example of defining a custom 'page' parameter:

        qr|/([^/]+)/([^/]+)/page(\d+)\.html/?| => { names => [qw(app rm page)] },

SEE ALSO ^

CGI::Application, CGI::Application::Dispatch

syntax highlighting: