blib/lib/CGI/URI2param.pm

filter: Statementstmt 96.4% 27 / 28 Branchbran 60.0% 6 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 88.6% 39 / 44 SCAR 18.1
CC
6
Cov
87%
uri2param
6.4
BEGIN
1.0
BEGIN
1.0
CRAP 6.1
« Build ↑ Summary blib/lib/Apache/URI2param.pm »
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 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 3 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 3 ▶use vars qw(@ISA @EXPORT_OK);
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 3 @ISA = qw(Exporter);
20  
21 3 @EXPORT_OK = qw(uri2param);
22  
23 3 $CGI::URI2param::VERSION = '1.01';
24  
25 sub uri2param {
26 1 ▶ my ($req,$regexs,$options)=@_;
Subroutine uri2param: called CC=6 SCAR=18.6
Pod documented
27  
28 # options not implemented, possible options are:
29 # -> don't safe in $q->param but return parsed stuff as hash/array
30 # -> use URI instead of PATH_INFO
31  
32 # check if $req seems to be a valid request object
33 1 ▶ croak "CGI::URI2param: not a valid request object" unless $req->can('param');
Branch: 1 branch
BranchTrueFalseTotal
unless $req->can("param") 0 1 1
34  
35 # check environment and set stuff
36 1 my $uri;
37 1 ▶ if ($ENV{MOD_PERL}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{'MOD_PERL'}) { } 0 1 1
38 0 $uri=$req->uri;
39 } else {
40 1 $uri=$req->url . $req->path_info;
41 }
42  
43 # apply regexes
44 1 eval {
45 1 ▶ while(my($key,$regex)=each(%$regexs)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$regexs) 2 1 3
46 2 ▶ if ($uri=~m/$regex/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($uri =~ /$regex/) 2 0 2
47 2 $req->param($key,$+);
48 }
49 }
50 };
51  
52 1 ▶ croak $@ if ($@);
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 1 1
53
54 1 return 1;
55 }
56  
57 3 1;
58  
59 __END__
« Build ↑ Summary blib/lib/Apache/URI2param.pm »