CGI::Application::Dispatch::Regexp - Dispatch requests to CGI::Application based objects using regular expressions
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)] }, ], );
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.
CGI::Application::Dispatch::Regexp
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)] },
CGI::Application, CGI::Application::Dispatch
To install CGI::Application::Dispatch, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CGI::Application::Dispatch
CPAN shell
perl -MCPAN -e shell install CGI::Application::Dispatch
For more information on module installation, please visit the detailed CPAN module installation guide.