CGI::Dispatcher::Simple - Simple CGI Dispacher by PATH_INFO
# In your App package MyApp; use base qw/CGI::Dispacher::Simple/; sub run { my $self = shift; $self->dispatch({ '/' => 'default', '/list' => 'list', '/add' => 'add', }); } sub default { : } : # And in your CGI script my $app = MyApp->new; $app->run;
This module provide you to simple dispatcher by using PATH_INFO.
You can set some methods as hashref, PATH_INFO are keys, METHODS are values. like:
'/' => 'default', '/list/add' => 'add',
And, rest of PATH_INFO is saved in $self->args as arrayref. When PATH_INFO is '/list/add/foo/bar' in above example, $self->args is:
[ 'foo', 'bar' ]
If you define $self->begin or $self->end methods, these are called automatically before/after PATH_INFO method.
And when PATH_INFO is not defined, dispatch to '/' method.
Daisuke Murase <typester@cpan.org>
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
To install CGI::Dispatcher::Simple, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CGI::Dispatcher::Simple
CPAN shell
perl -MCPAN -e shell install CGI::Dispatcher::Simple
For more information on module installation, please visit the detailed CPAN module installation guide.