line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
2
|
|
|
|
|
|
|
# CGI::URI2param - convert parts of an URL to param values |
3
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
4
|
|
|
|
|
|
|
# Copyright Thomas Klausner / ZSI 2001,2002,2006 |
5
|
|
|
|
|
|
|
# You may use and distribute this module according to the same terms |
6
|
|
|
|
|
|
|
# that Perl is distributed under. |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# Thomas Klausner domm@cpan.org http://domm.plix.at |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package CGI::URI2param; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# ABSTRACT: convert parts of an URL to param values |
15
|
|
|
|
|
|
|
our $VERSION = '1.02'; # VERSION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
warn __PACKAGE__ .' is DEPRECATED, please do not use this module anymore'; |
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
2
|
|
137270
|
use strict; |
|
2
|
|
|
|
|
15
|
|
|
2
|
|
|
|
|
63
|
|
20
|
2
|
|
|
2
|
|
10
|
use Carp; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
104
|
|
21
|
2
|
|
|
2
|
|
12
|
use Exporter; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
123
|
|
22
|
2
|
|
|
2
|
|
13
|
use vars qw(@ISA @EXPORT_OK); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
594
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
@EXPORT_OK = qw(uri2param); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
$CGI::URI2param::VERSION = '1.01'; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub uri2param { |
31
|
1
|
|
|
1
|
1
|
693
|
my ($req,$regexs,$options)=@_; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# options not implemented, possible options are: |
34
|
|
|
|
|
|
|
# -> don't safe in $q->param but return parsed stuff as hash/array |
35
|
|
|
|
|
|
|
# -> use URI instead of PATH_INFO |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# check if $req seems to be a valid request object |
38
|
1
|
50
|
|
|
|
8
|
croak "CGI::URI2param: not a valid request object" unless $req->can('param'); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# check environment and set stuff |
41
|
1
|
|
|
|
|
3
|
my $uri; |
42
|
1
|
50
|
|
|
|
5
|
if ($ENV{MOD_PERL}) { |
43
|
0
|
|
|
|
|
0
|
$uri=$req->uri; |
44
|
|
|
|
|
|
|
} else { |
45
|
1
|
|
|
|
|
4
|
$uri=$req->url . $req->path_info; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# apply regexes |
49
|
1
|
|
|
|
|
8
|
eval { |
50
|
1
|
|
|
|
|
6
|
while(my($key,$regex)=each(%$regexs)) { |
51
|
2
|
50
|
|
|
|
64
|
if ($uri=~m/$regex/) { |
52
|
2
|
|
|
|
|
7
|
$req->param($key,$+); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
}; |
56
|
|
|
|
|
|
|
|
57
|
1
|
50
|
|
|
|
12
|
croak $@ if ($@); |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
7
|
return 1; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |