line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Revision: 1.5 $ |
3
|
|
|
|
|
|
|
# $Source: /home/cvs/CGI-PathParam/lib/CGI/PathParam.pm,v $ |
4
|
|
|
|
|
|
|
# $Date: 2006/06/01 06:23:22 $ |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
package CGI::PathParam; |
7
|
2
|
|
|
2
|
|
92764
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
71
|
|
8
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
370
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
CGI::PathParam - Add the feature of parsing path_info to CGI. |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
0.04 |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use CGI; |
25
|
|
|
|
|
|
|
use CGI::PathParam; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $q = CGI->new; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
$q->path_param(qw(foo bar baz)); # same as $q->path_info('/foo/bar/baz') |
30
|
|
|
|
|
|
|
my @results = $q->path_param; # @results is ( 'foo', 'bar', 'baz' ). |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 DESCRIPTION |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
This module adds the feature of parsing PATH_INFO to CGI as a plugin. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 path_param(@) |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
If the arguments are specified, the values joined by / is set to path_info. |
41
|
|
|
|
|
|
|
Otherwise, it returns the list of path_info split. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub path_param { |
46
|
15
|
|
|
15
|
1
|
14545
|
my $self = shift; |
47
|
|
|
|
|
|
|
|
48
|
15
|
100
|
|
|
|
41
|
if (@_) { |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# When path_info(undef), only returns current path_info data. |
51
|
|
|
|
|
|
|
# The behavior is same as path_info() |
52
|
|
|
|
|
|
|
# However, that of path_param(undef) is *NOT* same as path_param(). |
53
|
|
|
|
|
|
|
# Because path_param($param) occurs two kinds of behavior |
54
|
|
|
|
|
|
|
# whether $param is undef or not. |
55
|
|
|
|
|
|
|
|
56
|
8
|
|
|
|
|
14
|
$self->path_info( join q{/}, map { $self->escape($_) } @_ ); |
|
10
|
|
|
|
|
44
|
|
57
|
|
|
|
|
|
|
|
58
|
8
|
|
|
|
|
704
|
return $self; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
7
|
100
|
|
|
|
131
|
if ( !$self->path_info ) { |
62
|
1
|
|
|
|
|
36
|
return; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
6
|
|
|
|
|
241
|
return map { $self->unescape($_) } |
|
7
|
|
|
|
|
152
|
|
66
|
|
|
|
|
|
|
split m{/}msx, substr $self->path_info, 1; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
*CGI::path_param = \&path_param; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=over |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item Use of uninitialized value in join or string at ... |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
If you pass undef to path_param then you will see this message. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=back |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 CONFIGURATION AND ENVIRONMENT |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
L |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 INCOMPATIBILITIES |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
The path_param() does not provide a setter feature yet. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
94
|
|
|
|
|
|
|
C, or through the web interface at |
95
|
|
|
|
|
|
|
L. |
96
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
97
|
|
|
|
|
|
|
your bug as I make changes. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
perldoc CGI::PathParam |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
You can also look for information at: |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=over 4 |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
L |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item * CPAN Ratings |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
L |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
L |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item * Search CPAN |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
L |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=back |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 AUTHOR |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Hironori Yoshida, C<< >> |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Copyright 2006 Hironori Yoshida, all rights reserved. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
134
|
|
|
|
|
|
|
under the same terms as Perl itself. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=cut |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1; # End of CGI::PathParam |