CGI::Application::Dispatch::Regexp(3pm)

CGI::Application::Dispatch::Regexp3pm

Dispatch requests to cgi::application based objects using regular expressions

Usage

    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)]
                                                     },
        ],
    );

Overview

CGI::Application::Dispatch uses its own syntax dispatch table. "CGI::Application::Dispatch::Regexp" allows one to use flexible and powerful Perl regular expressions to transform a path 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)],
        },

Releases

8 releases since Debian 6.0 (Squeeze); the text changed 5 times.

  1. 6.0
  2. 7
  3. 8
  4. 9–10
  5. 11
  6. 12–13

From libcgi-application-dispatch-perl 3.12-3 in Debian 13 (Trixie). Parsed by carta from the page's man source.