1CGI::Application::DispaUtscehr::CRoengterxipb(u3t)ed PerClGID:o:cAupmpelnitcaattiioonn::Dispatch::Regexp(3)
2
3
4
6 CGI::Application::Dispatch::Regexp - Dispatch requests to
7 CGI::Application based objects using regular expressions
8
10 use CGI::Application::Dispatch::Regexp;
11
12 CGI::Application::Dispatch::Regexp->dispatch(
13 prefix => 'MyApp',
14 table => [
15 '' => { app => 'Welcome', rm => 'start' },
16 qr|/([^/]+)/?| => { names => ['app'] },
17 qr|/([^/]+)/([^/]+)/?| => { names => [qw(app rm)] },
18 qr|/([^/]+)/([^/]+)/page(\d+)\.html?| => { names => [qw(app rm page)] },
19 ],
20 );
21
23 CGI::Application::Dispatch uses its own syntax dispatch table.
24 "CGI::Application::Dispatch::Regexp" allows to use flexible and
25 powerful Perl regular expressions to transform a path into argument
26 list.
27
29 The dispatch table should contain list of regular expressions with
30 hashref of corresponding parameters. Hash element 'names' is a list of
31 names of regular expression groups. The default table looks like this:
32
33 table => [
34 qr|/([^/]+)/?| => { names => ['app'] },
35 qr|/([^/]+)/([^/]+)/?| => { names => [qw(app rm)] },
36 ],
37
38 Here's an example of defining a custom 'page' parameter:
39
40 qr|/([^/]+)/([^/]+)/page(\d+)\.html/?| => { names => [qw(app rm page)] },
41
43 Copyright Michael Peters and Mark Stosberg 2008, all rights reserved.
44
46 CGI::Application, CGI::Application::Dispatch
47
48
49
50perl v5.12.0 2010-04-C3G0I::Application::Dispatch::Regexp(3)