NAME
CGI::Application::Dispatch::Regexp - Dispatch requests to CGI::Application based objects using regular expressions
SYNOPSIS
package MyApp::Dispatch;
use base 'CGI::Application::Dispatch';
sub args_to_dispatch {
return {
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
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.
table => [
qr|/([^/]+)/?| => { names => ['app'] },
qr|/([^/]+)/([^/]+)/?| => { names => [qw(app rm)] },
qr|/([^/]+)/([^/]+)/page(\d+)\.html/?| => { names => [qw(app rm page)] },
]