More Related Content
More from Andrew Shitov (20)
My four preferences in Perl Web practices
- 2. My Four
Preferences
in my Perl Web practice
- 14. My Four
Preferences
in my Perl Web practice
- 15. 1. Parsing URLs with grammar
2. .ini configuration files
3. WWW::Page
4. XSLT
- 20. URL is . . .
a string,
a set of parts
- 21. URL is . . .
a string,
a set of parts,
a container of parameters
- 39. How to parse?
Regular expressions
given ($uri) {
when (/^/$/) {...}
when (/^/post/?/) {...}
# (regexes as in .htaccess)
}
- 42. How to parse?
split builtin
@parts = split m{/}, $uri;
given (scalar @parts) {
when (1) {...}
when (2) {...}
}
- 68. my %uri = (
'/' => {
'type' => 'index',
},
'/alpha/' => {
'type' => 'section',
'sectionUri' => 'alpha',
'sectionPage' => 1,
},
'/beta‐2/34/14/' => {
'type' => 'message',
'sectionUri' => 'beta',
'sectionPage' => 2,
'threadID' => 34,
'threadPage' => 1,
'messageID' => 14,
},
'/‐/' => {
'type' => '404',
});
- 87. global.ini local.ini
[page]
length=10
[db] [db]
host=db.int host=localhost
port=3333 port=3306