| 1 | package CGI::PathInfo; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 6 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 6 | $CGI::PathInfo::VERSION = '1.06'; | |||||||||||||||||||||||||||
| 8 | 6 | $CGI::PathInfo::_mod_perl = 0; | |||||||||||||||||||||||||||
| 9 | } | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | # check for mod_perl and include the 'Apache' module if needed | ||||||||||||||||||||||||||||
| 12 | 6 | ▶ | if (exists($ENV{'MOD_PERL'}) && (0 == $CGI::PathInfo::_mod_perl)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $ENV{"MOD_PERL"} and 0 == $CGI::PathInfo::_mod_perl
MC/DC50%1/2
exists $ENV{"MOD_PERL"} and 0 == $CGI::PathInfo::_mod_perl
exists $ENV{"MOD_PERL"}
0 == $CGI::PathInfo::_mod_perl
Truth table66%2/3
A and B
A= exists $ENV{"MOD_PERL"}B= 0 == $CGI::PathInfo::_mod_perl
| |||||||||||||||||||||||||||||
| 13 | 1 | $| = 1; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | if (exists ($ENV{MOD_PERL_API_VERSION}) && ($ENV{MOD_PERL_API_VERSION} == 2)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $ENV{"MOD_PERL_API_VERSION"} and $ENV{"MOD_PERL_API_VERSION"} == 2
MC/DC0%0/2
exists $ENV{"MOD_PERL_API_VERSION"} and $ENV{"MOD_PERL_API_VERSION"} == 2
exists $ENV{"MOD_PERL_API_VERSION"}
$ENV{"MOD_PERL_API_VERSION"} == 2
Truth table33%1/3
A and B
A= exists $ENV{"MOD_PERL_API_VERSION"}B= $ENV{"MOD_PERL_API_VERSION"} == 2
| |||||||||||||||||||||||||||||
| 16 | 0 | require Apache2::RequestUtil; | |||||||||||||||||||||||||||
| 17 | 0 | require Apache2::RequestIO; | |||||||||||||||||||||||||||
| 18 | 0 | require APR::Pool; | |||||||||||||||||||||||||||
| 19 | 0 | $CGI::PathInfo::_mod_perl = 2; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | } else { | ||||||||||||||||||||||||||||
| 22 | 1 | require Apache; | |||||||||||||||||||||||||||
| 23 | 1 | $CGI::PathInfo::_mod_perl = 1; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 36 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||
| 28 | 36 | my $proto = shift; | |||||||||||||||||||||||||||
| 29 | 36 | my $package = __PACKAGE__; | |||||||||||||||||||||||||||
| 30 | 36 | my $class; | |||||||||||||||||||||||||||
| 31 | 36 | ▶ | if (ref($proto)) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 32 | 2 | $class = ref ($proto); | |||||||||||||||||||||||||||
| 33 | } elsif ($proto) { | ||||||||||||||||||||||||||||
| 34 | 32 | $class = $proto; | |||||||||||||||||||||||||||
| 35 | } else { | ||||||||||||||||||||||||||||
| 36 | 2 | $class = $package; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | 36 | my $self = bless {},$class; | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 36 | $self->{$package}->{'field_names'} = []; | |||||||||||||||||||||||||||
| 41 | 36 | $self->{$package}->{'field'} = {}; | |||||||||||||||||||||||||||
| 42 | 36 | $self->{$package}->{'settings'} = { | |||||||||||||||||||||||||||
| 43 | 'eq' => '-', | ||||||||||||||||||||||||||||
| 44 | 'spliton' => '/', | ||||||||||||||||||||||||||||
| 45 | 'stripleadingslash' => 1, | ||||||||||||||||||||||||||||
| 46 | 'striptrailingslash' => 1, | ||||||||||||||||||||||||||||
| 47 | }; | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 36 | my $parms; | |||||||||||||||||||||||||||
| 50 | 36 | ▶ | if ($#_ == 0) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 51 | 12 | $parms = shift; | |||||||||||||||||||||||||||
| 52 | } elsif ($#_ > 0) { | ||||||||||||||||||||||||||||
| 53 | 8 | ▶ | if (0 == $#_ % 2) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 2 | require Carp; | |||||||||||||||||||||||||||
| 55 | 2 | Carp::croak('[' . localtime(time) . "] [error] $package" . '::new() - odd number of passed parameters'); | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | 6 | %$parms = @_; | |||||||||||||||||||||||||||
| 58 | } else { | ||||||||||||||||||||||||||||
| 59 | 16 | $parms = {}; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | 34 | ▶ | if (ref($parms) ne 'HASH') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | 4 | require Carp; | |||||||||||||||||||||||||||
| 63 | 4 | Carp::croak('[' . localtime(time) . "] [error] $package" . '::new() - Passed parameters do not appear to be valid'); | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | 30 | my @parm_keys = keys %$parms; | |||||||||||||||||||||||||||
| 66 | 30 | foreach my $parm_name (@parm_keys) { | |||||||||||||||||||||||||||
| 67 | 20 | my $lc_parm_name = lc ($parm_name); | |||||||||||||||||||||||||||
| 68 | 20 | ▶ | if (not exists $self->{$package}->{'settings'}->{$lc_parm_name}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | 6 | require Carp; | |||||||||||||||||||||||||||
| 70 | 6 | Carp::croak('[' . localtime(time) . "] [error] $package" . "::new() - Passed parameter name '$parm_name' is not valid here"); | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | 14 | $self->{$package}->{'settings'}->{$lc_parm_name} = $parms->{$parm_name}; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | 24 | $self->_decode_path_info; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 24 | return $self; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | ####################################################################### | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 28 | ▶ | sub param { | ||||||||||||||||||||||||||
|
Subroutine
param: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||
| 82 | 28 | my $self = shift; | |||||||||||||||||||||||||||
| 83 | 28 | my $package = __PACKAGE__; | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 28 | ▶ | if (1 < @_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | 4 | my $n_parms = @_; | |||||||||||||||||||||||||||
| 87 | 4 | ▶ | if (($n_parms % 2) == 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | 1 | require Carp; | |||||||||||||||||||||||||||
| 89 | 1 | Carp::croak('[' . localtime(time) . "] [error] $package" . "::param() - Odd number of parameters passed"); | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | 3 | my $parms = { @_ }; | |||||||||||||||||||||||||||
| 92 | 3 | $self->_set($parms); | |||||||||||||||||||||||||||
| 93 | 2 | return; | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | 24 | ▶ | if ((@_ == 1) and (ref ($_[0]) eq 'HASH')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@_ == 1 and ref $_[0] eq "HASH"
MC/DC100%2/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1
ref $_[0] eq "HASH"
Truth table100%3/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||
| 96 | 1 | my $parms = shift; | |||||||||||||||||||||||||||
| 97 | 1 | $self->_set($parms); | |||||||||||||||||||||||||||
| 98 | 1 | return; | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 23 | my @result = (); | |||||||||||||||||||||||||||
| 102 | 23 | ▶ | if ($#_ == -1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | 8 | @result = @{$self->{$package}->{'field_names'}}; | |||||||||||||||||||||||||||
| 104 | } else { | ||||||||||||||||||||||||||||
| 105 | 15 | my ($fieldname)=@_; | |||||||||||||||||||||||||||
| 106 | 15 | ▶ | if (defined($self->{$package}->{'field'}->{$fieldname})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 107 | 13 | @result = @{$self->{$package}->{'field'}->{$fieldname}->{'value'}}; | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 23 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 113 | 17 | return @result; | |||||||||||||||||||||||||||
| 114 | } else { | ||||||||||||||||||||||||||||
| 115 | 6 | return $result[0]; | |||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | ####################################################################### | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 2 | ▶ | sub calling_parms_table { | ||||||||||||||||||||||||||
|
Subroutine
calling_parms_table: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 122 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 123 | 2 | my $package = __PACKAGE__; | |||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 2 | require HTML::Entities; | |||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 2 | my $outputstring = "<table border=\"1\" cellspacing=\"0\"><tr><th colspan=\"2\">PATH_INFO Fields</th></tr><tr><th>Field</th><th>Value</th></tr>\n"; | |||||||||||||||||||||||||||
| 128 | 2 | my @field_list = $self->param; | |||||||||||||||||||||||||||
| 129 | 2 | foreach my $fieldname (sort @field_list) { | |||||||||||||||||||||||||||
| 130 | 3 | my @values = $self->param($fieldname); | |||||||||||||||||||||||||||
| 131 | 3 | my $sub_field_counter= $#values; | |||||||||||||||||||||||||||
| 132 | 3 | ▶ | for (my $fieldn=0; $fieldn <= $sub_field_counter; $fieldn++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 133 | 3 | my $e_fieldname = HTML::Entities::encode_entities($fieldname); | |||||||||||||||||||||||||||
| 134 | 3 | my $fieldvalue = HTML::Entities::encode_entities($values[$fieldn]); | |||||||||||||||||||||||||||
| 135 | 3 | $outputstring .= "<tr><td>$e_fieldname (#$fieldn)</td><td> $fieldvalue</td></tr>\n"; | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 2 | $outputstring .= "</table>\n"; | |||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 2 | return $outputstring; | |||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | ####################################################################### | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 257 | ▶ | sub url_encode { | ||||||||||||||||||||||||||
|
Subroutine
url_encode: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 147 | 257 | my $self = shift; | |||||||||||||||||||||||||||
| 148 | 257 | my ($line) = @_; | |||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 257 | ▶ | return '' if (! defined ($line)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 151 | 256 | $line =~ s/([^a-zA-Z0-9])/"\%".unpack("H",$1).unpack("h",$1)/egs; | |||||||||||||||||||||||||||
| 152 | 256 | return $line; | |||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | ####################################################################### | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 358 | ▶ | sub url_decode { | ||||||||||||||||||||||||||
|
Subroutine
url_decode: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 158 | 358 | my $self = shift; | |||||||||||||||||||||||||||
| 159 | 358 | my ($line) = @_; | |||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | 358 | ▶ | return '' if (! defined ($line)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | 357 | $line =~ s/\+/ /gos; | |||||||||||||||||||||||||||
| 163 | 357 | $line =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/egs; | |||||||||||||||||||||||||||
| 164 | 357 | return $line; | |||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | ######################################################################## | ||||||||||||||||||||||||||||
| 169 | # Performs PATH_INFO decoding | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 24 | ▶ | sub _decode_path_info { | ||||||||||||||||||||||||||
|
Subroutine
_decode_path_info: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||
| 172 | 24 | my $self = shift; | |||||||||||||||||||||||||||
| 173 | 24 | my $package = __PACKAGE__; | |||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 24 | my $buffer = ''; | |||||||||||||||||||||||||||
| 176 | 24 | ▶ | if (1 == $CGI::PathInfo::_mod_perl) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 177 | 10 | $buffer = Apache->request->path_info; | |||||||||||||||||||||||||||
| 178 | } elsif (2 == $CGI::PathInfo::_mod_perl) { | ||||||||||||||||||||||||||||
| 179 | 0 | $buffer = Apache2::RequestUtil->request->path_info; | |||||||||||||||||||||||||||
| 180 | } else { | ||||||||||||||||||||||||||||
| 181 | 14 | ▶ | $buffer = $ENV{'PATH_INFO'} if (defined $ENV{'PATH_INFO'}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | 24 | $self->_burst_URL_encoded_buffer($buffer); | |||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | 24 | return; | |||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | ########################################################################## | ||||||||||||||||||||||||||||
| 189 | # Bursts normal URL encoded buffers | ||||||||||||||||||||||||||||
| 190 | # Takes: $buffer - the actual data to be burst | ||||||||||||||||||||||||||||
| 191 | # | ||||||||||||||||||||||||||||
| 192 | # parameters are presumed to be seperated by ';' characters | ||||||||||||||||||||||||||||
| 193 | # | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | 24 | ▶ | sub _burst_URL_encoded_buffer { | ||||||||||||||||||||||||||
|
Subroutine
_burst_URL_encoded_buffer: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||
| 196 | 24 | my $self = shift; | |||||||||||||||||||||||||||
| 197 | 24 | my $package = __PACKAGE__; | |||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | 24 | my ($buffer) = @_; | |||||||||||||||||||||||||||
| 200 | 24 | my $settings = $self->{$package}->{'settings'}; | |||||||||||||||||||||||||||
| 201 | 24 | ▶ | if ($settings->{'stripleadingslash'}) { $buffer =~ s#^/+##s; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 202 | 24 | ▶ | if ($settings->{'striptrailingslash'}) { $buffer =~ s#/+$##s; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 24 | my $spliton = $settings->{'spliton'}; | |||||||||||||||||||||||||||
| 205 | 24 | my $eq_mark = $settings->{'eq'}; | |||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | # Split the name-value pairs on the selected split char | ||||||||||||||||||||||||||||
| 208 | 24 | my @pairs = (); | |||||||||||||||||||||||||||
| 209 | 24 | ▶ | if ($buffer) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 210 | 22 | @pairs = split(/$spliton/, $buffer); | |||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | # Initialize the field hash and the field_names array | ||||||||||||||||||||||||||||
| 214 | 24 | $self->{$package}->{'field'} = {}; | |||||||||||||||||||||||||||
| 215 | 24 | $self->{$package}->{'field_names'} = []; | |||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | 24 | foreach my $pair (@pairs) { | |||||||||||||||||||||||||||
| 218 | 74 | my ($name, $data) = split(/$eq_mark/,$pair,2); | |||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | # Anything that didn't split is omitted from the output | ||||||||||||||||||||||||||||
| 221 | 74 | ▶ | next if (not defined $data); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | # De-URL encode %-encoding | ||||||||||||||||||||||||||||
| 224 | 50 | $name = $self->url_decode($name); | |||||||||||||||||||||||||||
| 225 | 50 | $data = $self->url_decode($data); | |||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 50 | ▶ | if (! defined ($self->{$package}->{'field'}->{$name}->{'count'})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 228 | 44 | push (@{$self->{$package}->{'field_names'}},$name); | |||||||||||||||||||||||||||
| 229 | 44 | $self->{$package}->{'field'}->{$name}->{'count'} = 0; | |||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||
| 231 | 50 | my $record = $self->{$package}->{'field'}->{$name}; | |||||||||||||||||||||||||||
| 232 | 50 | my $field_count = $record->{'count'}; | |||||||||||||||||||||||||||
| 233 | 50 | $record->{'count'}++; | |||||||||||||||||||||||||||
| 234 | 50 | $record->{'value'}->[$field_count] = $data; | |||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||
| 236 | 24 | return; | |||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | ################################################################## | ||||||||||||||||||||||||||||
| 240 | # | ||||||||||||||||||||||||||||
| 241 | # Sets values into the object directly | ||||||||||||||||||||||||||||
| 242 | # Pass an anon hash for name/value pairs. Values may be | ||||||||||||||||||||||||||||
| 243 | # anon lists or simple strings | ||||||||||||||||||||||||||||
| 244 | # | ||||||||||||||||||||||||||||
| 245 | ################################################################## | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | 4 | ▶ | sub _set { | ||||||||||||||||||||||||||
|
Subroutine
_set: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 248 | 4 | my $self = shift; | |||||||||||||||||||||||||||
| 249 | 4 | my $package = __PACKAGE__; | |||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | 4 | my ($parms) = @_; | |||||||||||||||||||||||||||
| 252 | 4 | foreach my $name (keys %$parms) { | |||||||||||||||||||||||||||
| 253 | 4 | my $value = $parms->{$name}; | |||||||||||||||||||||||||||
| 254 | 4 | my $data = []; | |||||||||||||||||||||||||||
| 255 | 4 | my $data_type = ref $value; | |||||||||||||||||||||||||||
| 256 | 4 | ▶ | if (not $data_type) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 257 | 2 | $data = [ $value ]; | |||||||||||||||||||||||||||
| 258 | } elsif ($data_type eq 'ARRAY') { | ||||||||||||||||||||||||||||
| 259 | # Shallow copy the anon array to prevent action at a distance | ||||||||||||||||||||||||||||
| 260 | 1 | @$data = map {$_} @$value; | |||||||||||||||||||||||||||
| 261 | } else { | ||||||||||||||||||||||||||||
| 262 | 1 | require Carp; | |||||||||||||||||||||||||||
| 263 | 1 | Carp::croak ('[' . localtime(time) . "] [error] $package" . "::_set() - Parameter '$name' has illegal data type of '$data_type'"); | |||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | 3 | ▶ | if (! defined ($self->{$package}->{'field'}->{$name}->{'count'})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 267 | 1 | push (@{$self->{$package}->{'field_names'}},$name); | |||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||
| 269 | 3 | my $record = {}; | |||||||||||||||||||||||||||
| 270 | 3 | $self->{$package}->{'field'}->{$name} = $record; | |||||||||||||||||||||||||||
| 271 | 3 | $record->{'count'} = @$data; | |||||||||||||||||||||||||||
| 272 | 3 | $record->{'value'} = $data; | |||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||
| 274 | 3 | return; | |||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | ########################################################################## | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | 6 | 1; | |||||||||||||||||||||||||||