| 1 | package YATT::Lite::Util; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 84 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 84 | ▶ | use warnings qw(FATAL all NONFATAL misc); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 84 | ▶ | use constant DEBUG_LOOKUP_PATH => $ENV{DEBUG_YATT_UTIL_LOOKUP_PATH}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 78 | ▶ | use Encode (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 78 | ▶ | use URI::Escape (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 78 | ▶ | use Tie::IxHash; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 72 | require Scalar::Util; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 72 | require File::Spec; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | package YATT::Lite::Util; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 78 | ▶ | use Exporter qw(import); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 78 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 78 | $INC{'YATT/Lite/Util.pm'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 81 | our @EXPORT = qw/numLines coalesce default globref symtab lexpand escape | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | untaint_any ckeval ckrequire untaint_unless_tainted | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | dict_sort terse_dump catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | nonempty | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | empty | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | subname | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | pkg2pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | globref_default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | dumpout | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | /; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 78 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 8840 | ▶ | sub numLines { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
numLines: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 8840 | ▶ | croak "undefined value for numLines!" unless defined $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 8840 | $_[0] =~ tr|\n||; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 3036 | ▶ | sub coalesce { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coalesce: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 3036 | foreach my $item (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 6042 | ▶ | return $item if defined $item; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 72 | *default = \*coalesce; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 703 | ▶ | sub nonempty { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nonempty: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 703 | ▶ | defined $_[0] && $_[0] ne ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 576 | ▶ | sub empty { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
empty: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 576 | ▶ | not defined $_[0] or $_[0] eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 6481 | ▶ | sub define_const { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
define_const: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 6481 | my ($name_or_glob, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 6481 | ▶ | my $glob = ref $name_or_glob ? $name_or_glob : globref($name_or_glob); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 6481 | ▶ | *$glob = my $const_sub = sub () { $value }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 6481 | $const_sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 97187 | ▶ | sub globref { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
globref: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 97187 | my ($thing, @name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 97187 | ▶ | my $class = ref $thing || $thing; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
ref $thing || $thing
MC/DC0%0/2
ref $thing || $thing
ref $thing
$thing
Truth table66%2/3
A || B
A= ref $thingB= $thing
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 78 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 97187 | \*{join("::", $class, grep {defined} @name)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 369 | ▶ | sub globref_default { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
globref_default: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 369 | ▶ | unless (@_ == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | croak "Too few arguments"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 369 | my ($globref, $default) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 369 | my $kind = ref $default; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 369 | ▶ | *{$globref}{$kind} || do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 364 | *{$globref} = $default; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 364 | $default; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 41829 | ▶ | sub symtab { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
symtab: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 41829 | *{globref(shift, '')}{HASH} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 41829 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # XXX: Nice to have look_for_symtab, too. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 37854 | ▶ | sub look_for_globref { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
look_for_globref: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 37854 | my ($class, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 37854 | my $symtab = symtab($class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 37854 | ▶ | return undef unless defined $symtab->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 37509 | globref($class, $name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | sub call_ns_function_or_default { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
call_ns_function_or_default: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my ($class, $funcname, $default) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | my $symtab = symtab($class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | my ($glob, $code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | if (defined ($glob = $symtab->{$funcname}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
defined($glob = $symtab->{$funcname}) and $code = *{$glob;}{"CODE"}
MC/DC0%0/1
defined($glob = $symtab->{$funcname}) and $code = *{$glob;}{"CODE"}
defined($glob = $symtab->{$funcname})
Truth table0%0/2
A
A= defined($glob = $symtab->{$funcname})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | and ($code = *{$glob}{CODE})) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $code->() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | $default; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | sub ns_filename { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ns_filename: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my ($ns) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | if (my $fn = call_ns_function_or_default($ns, 'filename')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | "$ns \[$fn]" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | $ns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 33773 | ▶ | sub fields_hash { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fields_hash: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 33773 | ▶ | my $sym = look_for_globref(shift, 'FIELDS') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 33735 | *{$sym}{HASH}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # XXX: should be renamed to lhexpand | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 11239 | ▶ | sub lexpand { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lexpand: called CC=7 SCAR=20.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | # lexpand can be used to counting. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 11239 | ▶ | unless (defined $_[0]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 3229 | ▶ | wantarray ? () : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } elsif (not ref $_[0]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 4021 | $_[0] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } elsif (ref $_[0] eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 3976 | @{$_[0]} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } elsif (ref $_[0] eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 13 | %{$_[0]} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | wantarray ? () : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | sub lsearch (&@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lsearch: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my $sub = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | foreach (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | return $i if $sub->($_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | } continue {$i++} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | # $fn:e | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 169 | ▶ | sub extname { my $fn = shift; return $1 if $fn =~ s/\.(\w+)$// } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extname: called CC=2 SCAR=7.2
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | # $fn:r | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 1491 | ▶ | sub rootname { my $fn = shift; $fn =~ s/\.\w+$//; join "", $fn, @_ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rootname: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | # $fn:r:t | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | # GH-251: trim_ext($fn, $ext_or_list) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | # Trims one trailing ".$ext" only when $ext is a KNOWN extension. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | # (cf. cut_ext, which extracts ANY last extension) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | # This follows Apache mod_mime/mod_negotiation model: "foo.tar.yatt" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | # minus known ext "yatt" is "foo.tar", and "foo.bar" with unknown | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | # ext is left as-is. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 29 | ▶ | sub trim_ext { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trim_ext: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 29 | my ($fn, $ext_or_list) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 29 | ▶ | return undef unless defined $fn; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 28 | ▶ | foreach my $ext (lexpand($ext_or_list // 'yatt')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$ext_or_list // "yatt"
MC/DC100%1/1
$ext_or_list // "yatt"
$ext_or_list
Truth table100%2/2
A
A= $ext_or_list
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 29 | (my $e = $ext) =~ s/^\.//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 29 | ▶ | return $fn if $fn =~ s/\.\Q$e\E\z//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 6 | $fn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 58 | ▶ | sub appname { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
appname: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 58 | my $fn = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 58 | $fn =~ s/\.\w+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 58 | ▶ | return $1 if $fn =~ m{(\w+)$}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 960 | ▶ | sub untaint_any { $_[0] =~ m{.*}s; $& } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
untaint_any: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 72 | our $DEBUG_INJECT_TAINTED = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # untaint_unless_tainted($fn, read_file($fn)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 592 | ▶ | sub untaint_unless_tainted { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
untaint_unless_tainted: called CC=5 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 592 | ▶ | return $_[1] unless ${^TAINT}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | if (defined $_[0] and not Scalar::Util::tainted($_[0])) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $_[0] and not &Scalar::Util::tainted($_[0])
MC/DC0%0/2
defined $_[0] and not &Scalar::Util::tainted($_[0])
defined $_[0]
not &Scalar::Util::tainted($_[0])
Truth table0%0/3
A and not(B)
A= defined $_[0]B= not &Scalar::Util::tainted($_[0])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | $DEBUG_INJECT_TAINTED ? $_[1] : untaint_any($_[1]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 1875 | ▶ | sub ckeval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ckeval: called CC=9 SCAR=22.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | my $__SCRIPT__ = join "", grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 1875 | ▶ | defined $_ and Scalar::Util::tainted($_) ? croak "tainted! '$_'" : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $_ && (&Scalar::Util::tainted($_) ? croak("tainted! '${_}'") : 1)
MC/DC0%0/2
defined $_ && (&Scalar::Util::tainted($_) ? croak("tainted! '${_}'") : 1)
defined $_
(&Scalar::Util::tainted($_) ? croak("tainted! '${_}'") : 1)
Truth table33%1/3
A && B
A= defined $_B= (&Scalar::Util::tainted($_) ? croak("tainted! '${_}'") : 1)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 1875 | my @__RESULT__; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 1875 | ▶ | if ($] < 5.014) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | @__RESULT__ = eval $__SCRIPT__; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | $__RESULT__[0] = eval $__SCRIPT__; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | die $@ if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 1875 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 1875 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | @__RESULT__ = eval $__SCRIPT__; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 62 | ▶ | $__RESULT__[0] = eval $__SCRIPT__; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 1875 | ▶ | die $@ if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 1872 | ▶ | wantarray ? @__RESULT__ : $__RESULT__[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 1226 | ▶ | sub ckrequire { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ckrequire: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 1226 | ckeval("require $_[0]"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | # permissive_require($modName) allows you to load other module without worrying | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | # about their internal use of `eval { require OtherMod }` which misfires the error_handler of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | # YATT::Lite::WebMVC0::DirApp. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 39 | ▶ | sub permissive_require { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
permissive_require: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 40 | local ($SIG{__DIE__}, $SIG{__WARN__}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 43 | ckrequire($_[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 78 | ▶ | use Scalar::Util qw(refaddr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 1058 | ▶ | sub cached_in { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cached_in: called CC=11 SCAR=24.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 1062 | my ($dir, $dict, $nameSpec, $sys, $mark, $loader, $refresher) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 1062 | my ($name) = lexpand($nameSpec); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 1062 | ▶ | if (not exists $dict->{$name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 361 | ▶ | my $item = $dict->{$name} = $loader ? $loader->($dir, $sys, $nameSpec) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | : $dir->load($sys, $nameSpec); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 353 | ▶ | $mark->{refaddr($item)} = 1 if $item and $mark; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$item and $mark
MC/DC100%2/2
$item and $mark
$item
$mark
Truth table100%3/3
A and B
A= $itemB= $mark
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 353 | $item; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 697 | my $item = $dict->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 698 | ▶ | unless ($item and ref $item | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%9/9
$item and ref $item and not $mark && $$mark{builtin::refaddr($item)}++
$item and ref $item
$mark && $$mark{builtin::refaddr($item)}++
MC/DC100%4/4
$item and ref $item and not $mark && $$mark{builtin::refaddr($item)}++
$item
ref $item
$mark
$$mark{builtin::refaddr($item)}++
Truth table100%5/5
A and B and not(C && D)
A= $itemB= ref $itemC= $markD= $$mark{builtin::refaddr($item)}++
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | and (not $mark or not $mark->{refaddr($item)}++)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | # nop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } elsif ($refresher) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 45 | $refresher->($item, $sys, $nameSpec) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } elsif (my $sub = UNIVERSAL::can($item, 'refresh')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 261 | $sub->($item, $sys); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 698 | $item; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 54 | ▶ | sub split_path { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
split_path: called CC=18 SCAR=29.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 55 | my ($path, $startDir, $cut_depth, $default_ext) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | # $startDir is $app_root. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | # $doc_root should resides under $app_root. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 55 | ▶ | $cut_depth //= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$cut_depth //= 1
MC/DC0%0/1
$cut_depth //= 1
$cut_depth
Truth table50%1/2
A
A= $cut_depth
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 55 | ▶ | $default_ext //= "yatt"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$default_ext //= "yatt"
MC/DC100%1/1
$default_ext //= "yatt"
$default_ext
Truth table100%2/2
A
A= $default_ext
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 55 | $startDir =~ s,/+$,,; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 55 | ▶ | unless ($path =~ m{^\Q$startDir\E}gxs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 1 | die "Can't split_path: prefix mismatch: $startDir vs $path"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 55 | my ($dir, $pos, $file) = ($startDir, pos($path)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | # *DO NOT* initialize $file. This loop relies on undefined-ness of $file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 55 | ▶ | while ($path =~ m{\G/+([^/]*)}gcxs and -e "$dir/$1" and not defined $file) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$path =~ m[\G/+([^/]*)]cgsx and -e "$dir/$1" and not defined $file
$path =~ m[\G/+([^/]*)]cgsx and -e "$dir/$1"
MC/DC66%2/3
$path =~ m[\G/+([^/]*)]cgsx and -e "$dir/$1" and not defined $file
$path =~ m[\G/+([^/]*)]cgsx
-e "$dir/$1"
not defined $file
Truth table75%3/4
A and B and not(C)
A= $path =~ m[\G/+([^/]*)]cgsxB= -e "$dir/$1"C= not defined $file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 110 | ▶ | if (-d _) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 65 | $dir .= "/$1"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 46 | $file = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | # *DO NOT* last. To match one more time. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } continue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 110 | $pos = pos($path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 55 | ▶ | $dir .= "/" if $dir !~ m{/$}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 55 | my $subpath = substr($path, $pos); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | # GH-251: $request_file keeps the file name part as it appeared | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | # in $path (empty when the name is totally omitted). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 55 | my $request_file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 55 | ▶ | if (not defined $file) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 10 | ▶ | if ($subpath =~ m{^/(\w+)(?:/|$)} and -e "$dir/$1.$default_ext") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%2/3
$subpath =~ m[^/(\w+)(?:/|$)] and -e "$dir/$1.$default_ext"
MC/DC50%1/2
$subpath =~ m[^/(\w+)(?:/|$)] and -e "$dir/$1.$default_ext"
$subpath =~ m[^/(\w+)(?:/|$)]
-e "$dir/$1.$default_ext"
Truth table66%2/3
A and B
A= $subpath =~ m[^/(\w+)(?:/|$)]B= -e "$dir/$1.$default_ext"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 7 | $subpath = substr($subpath, 1+length $1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 7 | $request_file = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 7 | $file = "$1.$default_ext"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } elsif (-e "$dir/index.$default_ext") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | # index.yatt should subsume all subpath. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } elsif ($subpath =~ s{^/([^/]+)$}{}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | # Note: Actually, $file is not accesible in this case. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | # This is just for better error diag. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 1 | $file = $request_file = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 45 | $request_file = $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 54 | my $loc = substr($dir, length($startDir)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 54 | ▶ | while ($cut_depth-- > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 52 | ▶ | $loc =~ s,^/[^/]+,, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | or croak "Can't cut path location: $loc"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 52 | $startDir .= $&; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 54 | ▶ | ($startDir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%4/4
$file // ""
$request_file // ""
MC/DC100%1/1
$file // ""
$file
MC/DC100%1/1
$request_file // ""
$request_file
Truth table100%2/2
A
A= $file
Truth table100%2/2
A
A= $request_file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | , $loc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | , $file // '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | , $subpath | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | , (not defined $file) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | , $request_file // '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 568 | ▶ | sub lookup_dir { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_dir: called CC=4 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 568 | my ($loc, $dirlist) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 568 | $loc =~ s{^/*}{/}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 568 | foreach my $dir (@$dirlist) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 568 | my $real = "$dir$loc"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 568 | ▶ | next unless -d $real; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 568 | ▶ | return wantarray ? ($real, $dir) : $real; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 430 | ▶ | sub lookup_path { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_path: called CC=19 SCAR=29.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 429 | my ($path_info, $dirlist, $index_name, $ext_list, $use_subpath) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 429 | ▶ | $index_name //= 'index'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$index_name //= "index"
MC/DC100%1/1
$index_name //= "index"
$index_name
Truth table100%2/2
A
A= $index_name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 429 | my ($ext1, @ext) = lexpand($ext_list); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 429 | ▶ | $ext1 //= "yatt"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$ext1 //= "yatt"
MC/DC100%1/1
$ext1 //= "yatt"
$ext1
Truth table100%2/2
A
A= $ext1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 429 | my $ixfn = $index_name . ".$ext1"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 429 | ▶ | my @dirlist = grep {defined $_ and -d $_} @$dirlist; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
defined $_ && -d $_
MC/DC0%0/2
defined $_ && -d $_
defined $_
-d $_
Truth table33%1/3
A && B
A= defined $_B= -d $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 429 | print STDERR "dirlist" => terse_dump(@dirlist), "\n" if DEBUG_LOOKUP_PATH; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 429 | my $pi = normalize_path($path_info); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 429 | my ($loc, $cur, $ext) = ("", ""); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | DIG: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 429 | ▶ | while ($pi =~ s{^/+([^/]+)}{}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 440 | $cur = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 440 | ▶ | $ext = ($cur =~ s/(\.[^\.]+)$// ? $1 : undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 440 | print STDERR terse_dump(cur => $cur, ext => $ext), "\n" if DEBUG_LOOKUP_PATH; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 440 | foreach my $dir (@dirlist) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 468 | my $base = "$dir$loc/$cur"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 468 | ▶ | if (defined $ext and -r "$base$ext") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
defined $ext and -r "$base$ext"
MC/DC100%2/2
defined $ext and -r "$base$ext"
defined $ext
-r "$base$ext"
Truth table100%3/3
A and B
A= defined $extB= -r "$base$ext"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | # If extension is specified and it is readable, use it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 39 | return ($dir, "$loc/", "$cur$ext", $pi, 0, "$cur$ext"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | ▶ | } elsif ($pi =~ m{^/} and -d $base) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$pi =~ m[^/] and -d $base
MC/DC100%2/2
$pi =~ m[^/] and -d $base
$pi =~ m[^/]
-d $base
Truth table100%3/3
A and B
A= $pi =~ m[^/]B= -d $base
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | # path_info has '/' and directory exists. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 94 | next; # candidate | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 335 | foreach my $want_ext ($ext1, @ext) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 414 | ▶ | if (-r (my $fn = "$base.$want_ext")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | # GH-251: request_file must be a dot-boundary prefix of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | # the resolved file name (Apache MultiViews model), so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | # that only substrings of real file names can flow into | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | # url reconstruction. Thus a mismatching requested ext | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | # (e.g. request "foo.html" resolved to "foo.yatt") is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | # NOT reproduced here; $cur is used instead. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 190 | return ($dir, "$loc/", "$cur.$want_ext", $pi, 0, $cur); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 145 | ▶ | if ($use_subpath | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$use_subpath and -r (my $alt = "$dir$loc/$ixfn")
MC/DC100%2/2
$use_subpath and -r (my $alt = "$dir$loc/$ixfn")
$use_subpath
-r (my $alt = "$dir$loc/$ixfn")
Truth table100%3/3
A and B
A= $use_subpathB= -r (my $alt = "$dir$loc/$ixfn")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | and -r (my $alt = "$dir$loc/$ixfn")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 112 | ▶ | $ext //= ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ext //= ""
MC/DC0%0/1
$ext //= ""
$ext
Truth table50%1/2
A
A= $ext
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 112 | return ($dir, "$loc/", $ixfn, "/$cur$ext$pi", 1, ''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | # Neither dir nor $cur$want_ext exists, it should be ignored. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 33 | undef $dir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | } continue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 99 | $loc .= "/$cur"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 99 | print STDERR terse_dump(continuing => $loc), "\n" if DEBUG_LOOKUP_PATH; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 99 | @dirlist = grep {defined} @dirlist; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 88 | print STDERR terse_dump('end_of_loop'), "\n" if DEBUG_LOOKUP_PATH; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 88 | ▶ | return unless $pi =~ m{^/+$}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 83 | foreach my $dir (@dirlist) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 84 | ▶ | next unless -r "$dir$loc/$ixfn"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 83 | return ($dir, "$loc/", "$ixfn", "", 1, ''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | print STDERR terse_dump('at_last'), "\n" if DEBUG_LOOKUP_PATH; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | # Shamelessly stolen (with slight mod) from Dancer2::FileUtils::normalize_path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 72 | our $seqregex = qr{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | [^/]* # anything without a slash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | /\.\.(/|\z) # that is accompanied by two dots as such | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | }x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 439 | ▶ | sub normalize_path { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
normalize_path: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | # this is a revised version of what is described in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | # http://www.linuxjournal.com/content/normalizing-path-names-bash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | # by Mitch Frazier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 438 | ▶ | my $path = shift or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 438 | $path =~ s{/\./}{/}g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 438 | ▶ | 1 while $path =~ s{$seqregex}{}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | #see https://rt.cpan.org/Public/Bug/Display.html?id=80077 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 438 | $path =~ s{^//}{/}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 438 | return $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | # GH-260: lexical normalization for filesystem paths (app_root and its | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | # relatives). Unlike normalize_path above (PATH_INFO semantics, where a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | # trailing slash is significant), this collapses "." and ".." segments and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | # strips trailing slashes. Symlinks are deliberately not resolved, so a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | # deployment reached through a symlinked path keeps its spelling. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 415 | ▶ | sub normalize_fs_path { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
normalize_fs_path: called CC=12 SCAR=25.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 414 | my ($path) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 414 | ▶ | return $path unless defined $path and $path ne ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $path and $path ne ""
MC/DC0%0/2
defined $path and $path ne ""
defined $path
$path ne ""
Truth table33%1/3
A and B
A= defined $pathB= $path ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 414 | my $abs = substr($path, 0, 1) eq '/'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 414 | my @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 414 | foreach my $seg (split '/', $path) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 2235 | ▶ | next if $seg eq '' or $seg eq '.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$seg eq "" or $seg eq "."
MC/DC100%2/2
$seg eq "" or $seg eq "."
$seg eq ""
$seg eq "."
Truth table100%3/3
A or B
A= $seg eq ""B= $seg eq "."
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 1819 | ▶ | if ($seg eq '..') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 21 | ▶ | if (@out and $out[-1] ne '..') { pop @out; next; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@out and $out[-1] ne ".."
MC/DC50%1/2
@out and $out[-1] ne ".."
@out
$out[-1] ne ".."
Truth table66%2/3
A and B
A= @outB= $out[-1] ne ".."
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 2 | ▶ | next if $abs; # POSIX: "/.." means "/". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 1799 | push @out, $seg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 414 | my $result = join('/', @out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 414 | ▶ | $abs ? "/$result" : ($result ne '' ? $result : '.'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 31 | ▶ | sub trim_common_suffix_from { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trim_common_suffix_from: called CC=5 SCAR=16.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 30 | ▶ | @_ == 2 or Carp::croak "trim_common_suffix_from(FROM, COMPARE)"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 30 | my @from = File::Spec->splitdir($_[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 30 | my @comp = File::Spec->splitdir($_[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 30 | ▶ | while (@from and @comp and $from[-1] eq $comp[-1]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
@from and @comp and $from[-1] eq $comp[-1]
@from and @comp
MC/DC33%1/3
@from and @comp and $from[-1] eq $comp[-1]
@from
@comp
$from[-1] eq $comp[-1]
Truth table50%2/4
A and B and C
A= @fromB= @compC= $from[-1] eq $comp[-1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 60 | pop @from; pop @comp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 30 | File::Spec->catfile(@from); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 5 | ▶ | sub dict_order { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dict_order: called CC=7 SCAR=20.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 5 | my ($a, $b, $start) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 5 | ▶ | $start = 1 unless defined $start; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 5 | my ($result, $i) = (0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 5 | ▶ | for ($i = $start; $i <= $#$a and $i <= $#$b; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$i <= $a->$#* and $i <= $b->$#*
MC/DC0%0/2
$i <= $a->$#* and $i <= $b->$#*
$i <= $a->$#*
$i <= $b->$#*
Truth table33%1/3
A and B
A= $i <= $a->$#*B= $i <= $b->$#*
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 50 | ▶ | if ($a->[$i] =~ /^\d/ and $b->[$i] =~ /^\d/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$a->[$i] =~ /^\d/ and $b->[$i] =~ /^\d/
MC/DC50%1/2
$a->[$i] =~ /^\d/ and $b->[$i] =~ /^\d/
$a->[$i] =~ /^\d/
$b->[$i] =~ /^\d/
Truth table66%2/3
A and B
A= $a->[$i] =~ /^\d/B= $b->[$i] =~ /^\d/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 25 | $result = $a->[$i] <=> $b->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 25 | $result = $a->[$i] cmp $b->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 50 | ▶ | return $result unless $result == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | return $#$a <=> $#$b; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | # a => ['a', 'a'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | # q1a => ['q1a', 'q', 1, 'a'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | # q11b => ['q11b', 'q', 11, 'b'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 2 | ▶ | sub dict_sort (@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dict_sort: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 2 | map {$_->[0]} sort {dict_order($a,$b)} map {[$_, split /(\d+)/]} @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | sub dict_sort_by_nth ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dict_sort_by_nth: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | my $nth = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | map {$_->[0]} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | sort {dict_order($a,$b)} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | map {[$_, split /(\d+)/, $$_[$nth]]} @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 3 | ▶ | sub combination (@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
combination: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 3 | ▶ | my $comb; $comb = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 9 | my $prefix = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 9 | ▶ | return $prefix unless @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 9 | my ($list, @rest) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 9 | ▶ | if (@rest) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 3 | map {$comb->([@$prefix, $_], @rest)} @$list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 6 | map {[@$prefix, $_]} @$list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 3 | $comb->([], @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 4 | ▶ | sub captured (&;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
captured: called CC=4 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 4 | my ($code, $keep_utf8) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 4 | my $buffer = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 4 | ▶ | open my $fh, '>:utf8', \ $buffer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | or die "Can't create capture buf:$!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 4 | $code->($fh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 3 | ▶ | if ($keep_utf8 // 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$keep_utf8 // 1
MC/DC0%0/1
$keep_utf8 // 1
$keep_utf8
Truth table50%1/2
A
A= $keep_utf8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 3 | Encode::_utf8_on($buffer); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 3 | $buffer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 263 | ▶ | sub terse_dump { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
terse_dump: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 263 | require Data::Dumper; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | join ", ", map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 263 | Data::Dumper->new([$_])->Terse(1)->Indent(0)->Sortkeys(1)->Dump; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 13 | ▶ | sub indented_dump { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
indented_dump: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 13 | require Data::Dumper; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | join ", ", map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 13 | Data::Dumper->new([$_])->Terse(1)->Indent(1)->Sortkeys(1)->Dump; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | } @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 247 | ▶ | sub is_debugging { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_debugging: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 247 | ▶ | my $symtab = $main::{'DB::'} or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 247 | defined ${*{$symtab}{HASH}}{cmd_b} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 247 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 788 | ▶ | sub catch (&) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
catch: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 788 | my ($sub) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 788 | local $@ = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 788 | eval { $sub->() }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 788 | $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 72 | ▶ | sub add_entity_into { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_entity_into: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 1299 | my ($pack, $destns, $name, $sub, $allow_ignore) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 1299 | my $longname = join "::", $destns, "entity_$name"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 1299 | my $glob = globref($destns, "entity_$name"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 1299 | ▶ | if (*{$glob}{CODE} and $allow_ignore) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
*{$glob;}{"CODE"} and $allow_ignore
MC/DC50%1/2
*{$glob;}{"CODE"} and $allow_ignore
*{$glob;}{"CODE"}
$allow_ignore
Truth table66%2/3
A and B
A= *{$glob;}{"CODE"}B= $allow_ignore
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 8 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 1291 | subname($longname, $sub); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 1291 | *$glob = $sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 29 | ▶ | sub dofile_in { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dofile_in: called CC=3 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 29 | my ($pkg, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 29 | ▶ | unless (-e $file) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | croak "No such file: $file\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | } elsif (not -r _) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | croak "Can't read file: $file\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 29 | ckeval("package $pkg; my \$result = do '$file'; die \$\@ if \$\@; \$result"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 7 | ▶ | sub compile_file_in { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compile_file_in: called CC=4 SCAR=16.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 7 | my ($pkg, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 7 | ▶ | if (-d $file) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | croak "file '$file' is a directory!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 7 | my $sub = dofile_in($pkg, $file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 5 | ▶ | unless (defined $sub and ref $sub eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $sub and ref $sub eq "CODE"
MC/DC0%0/2
defined $sub and ref $sub eq "CODE"
defined $sub
ref $sub eq "CODE"
Truth table33%1/3
A and B
A= defined $subB= ref $sub eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | die "file '$file' should return CODE (but not)!\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 5 | $sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 78 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 78 | my %escape = (qw(< < | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | > > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | --> --> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | " " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | & &) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | , "\'", "'"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 78 | our $ESCAPE_UNDEF = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 682 | ▶ | sub escape { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
escape: called CC=13 SCAR=29.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 682 | ▶ | return if wantarray && !@_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
wantarray and not @_
MC/DC100%2/2
wantarray and not @_
wantarray
not @_
Truth table100%3/3
A and not(B)
A= wantarrayB= not @_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 681 | my @result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 681 | foreach my $str (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 681 | push @result, do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 681 | ▶ | unless (defined $str) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 17 | $ESCAPE_UNDEF; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | } elsif (not ref $str) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 636 | my $copy = $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 636 | $copy =~ s{([<>&\"\'])}{$escape{$1}}g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 636 | $copy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | } elsif (ref $str eq 'SCALAR') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | # PASS Thru. (Already escaped) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 8 | ▶ | $$str // $ESCAPE_UNDEF; # fail safe | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$$str // $YATT::Lite::Util::ESCAPE_UNDEF
MC/DC0%0/2
$$str // $YATT::Lite::Util::ESCAPE_UNDEF
$$str
$YATT::Lite::Util::ESCAPE_UNDEF
Truth table33%1/3
A // B
A= $$strB= $YATT::Lite::Util::ESCAPE_UNDEF
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } elsif (_is_escapable($str)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 7 | $str->as_escaped; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | } elsif (my $sub = UNIVERSAL::can($str, 'cf_pairs')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | ref($str).'->new('.(join(", ", map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | my ($k, $v) = @$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | "$k => " . do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | my $esc = escape($v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | ▶ | if (not defined $esc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | 'undef' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | } elsif ($esc eq '') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | "''" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | $esc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | } $sub->($str))).')'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | # XXX: Is this secure??? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | # XXX: Should be JSON? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 13 | my $copy = indented_dump($str); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 13 | $copy =~ s{([<\"]|-->)}{$escape{$1}}g; # XXX: Minimum. May be insecure. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 13 | $copy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 681 | ▶ | wantarray ? @result : $result[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | # XXX: Since method name "as_escaped" conflicts with CGen::Perl->as_escaped, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | # We need a informational class for everything safely escapable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | # via "as_escape()" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 20 | ▶ | sub _is_escapable { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_escapable: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 20 | UNIVERSAL::isa($_[0], 'YATT::Lite::Util::escapable'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | package | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | YATT::Lite::Util::escapable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 72 | package | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | YATT::Lite::Util::named_attr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 77 | ▶ | BEGIN {our @ISA = ('YATT::Lite::Util::escapable')}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 77 | ▶ | use overload qw("" as_string eq streq ne strne); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | ▶ | sub as_string { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | shift->[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 7 | ▶ | sub as_escaped { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_escaped: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 7 | sprintf q{ %s="%s"}, $_[0][0], $_[0][1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | ▶ | sub streq { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
streq: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | my ($self, $other) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | ▶ | $self->[-1] eq (ref $other ? $other->[-1] : $other); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | ▶ | sub strne { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
strne: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | my ($self, $other) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | ▶ | $self->[-1] ne (ref $other ? $other->[-1] : $other); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 72 | ▶ | sub named_attr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
named_attr: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 8 | my $attname = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 8 | ▶ | my @result = grep {defined $_ && $_ ne ''} @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
defined $_ && $_ ne ''
MC/DC100%2/2
defined $_ && $_ ne ''
defined $_
$_ ne ''
Truth table100%3/3
A && B
A= defined $_B= $_ ne ''
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 8 | ▶ | return '' unless @result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 7 | bless [$attname, join ' ', map {escape($_)} @result] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | , 'YATT::Lite::Util::named_attr'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | # XXX: These functions are deprecated. Use att_value_in() instead. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | ▶ | sub value_checked { _value_checked($_[0], $_[1], $_[2], checked => '') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
value_checked: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | ▶ | sub value_selected { _value_checked($_[0], $_[1], $_[2], selected => '') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
value_selected: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | ▶ | sub _value_checked { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_value_checked: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | my ($value, $hashOrArray, $isDefault, $then, $else) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | sprintf q|value="%s"%s|, escape($value), do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | ▶ | if (_if_checked($hashOrArray, $value) // $isDefault) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
_if_checked($hashOrArray, $value) // $isDefault
MC/DC0%0/2
_if_checked($hashOrArray, $value) // $isDefault
_if_checked($hashOrArray, $value)
$isDefault
Truth table0%0/3
A // B
A= _if_checked($hashOrArray, $value)B= $isDefault
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | " $then" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | ▶ | $else // '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$else // ""
MC/DC0%0/1
$else // ""
$else
Truth table0%0/2
A
A= $else
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | ▶ | sub _if_checked { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_if_checked: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | my ($in, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | ▶ | if (not defined $in) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | } elsif (not ref $in) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | ($in eq $value) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | } elsif (ref $in eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | ▶ | $in->{$value // ''} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$value // ""
MC/DC0%0/1
$value // ""
$value
Truth table0%0/2
A
A= $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | } elsif (ref $in eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | grep {$value eq $_} @$in | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 72 | our %input_spec = (select => [0, 0] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | , radio => [1, 0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | , checkbox => [2, 1]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | ▶ | sub att_value_in { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
att_value_in: not called CC=14 SCAR=53.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | my ($in, $type, $name, $formal_value, $as_value, $is_default) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | ▶ | defined (my $spec = $input_spec{$type}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | or croak "Unknown type: $type"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | my ($typeid, $has_sfx) = @$spec; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | ▶ | unless (defined $name and $name ne '') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $name and $name ne ""
MC/DC0%0/2
defined $name and $name ne ""
defined $name
$name ne ""
Truth table0%0/3
A and B
A= defined $nameB= $name ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | croak "name is empty"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | ▶ | unless (defined $formal_value and $formal_value ne '') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $formal_value and $formal_value ne ""
MC/DC0%0/2
defined $formal_value and $formal_value ne ""
defined $formal_value
$formal_value ne ""
Truth table0%0/3
A and B
A= defined $formal_valueB= $formal_value ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | croak "value is empty"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | my @res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | ▶ | if ($type and $typeid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$type and $typeid
MC/DC0%0/2
$type and $typeid
$type
$typeid
Truth table0%0/3
A and B
A= $typeB= $typeid
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | push @res, qq|type="$type"|; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | ▶ | if ($typeid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | ▶ | my $sfx = $has_sfx ? '['.escape($formal_value).']' : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | push @res, qq|name="@{[escape($name)]}$sfx"|; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | ▶ | if (not $has_sfx) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | # select | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | push @res, qq|value="@{[escape($formal_value)]}"|; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | } elsif ($as_value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | # checkbox/radio, with explicit value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | push @res, qq|value="@{[escape($as_value)]}"|; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | ▶ | if (find_value_in($in, $name, $formal_value, $is_default)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | ▶ | push @res, $typeid ? "checked" : "selected"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | join(" ", @res); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | ▶ | sub find_value_in { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_value_in: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | my ($in, $name, $formal_value, $is_default) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | ▶ | if (ref $in eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | return $in->{$formal_value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | my $actual_value = do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | ▶ | if (my $sub = UNIVERSAL::can($in, "param")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | $sub->($in, $name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | ▶ | if (not defined $actual_value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | ▶ | $is_default ? 1 : 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | } elsif (not ref $actual_value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | $actual_value eq $formal_value | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | } elsif (ref $actual_value eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | $actual_value->{$formal_value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | } elsif (ref $actual_value eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | ▶ | defined lsearch {$_ eq $formal_value} @$actual_value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | # Verbatimly stolen from CGI::Simple | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | # XXX: not used? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 72 | ▶ | sub url_decode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
url_decode: not called CC=2 SCAR=15.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | my ( $self, $decode ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | ▶ | return () unless defined $decode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | $decode =~ tr/+/ /; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | $decode =~ s/%([a-fA-F0-9]{2})/ pack "C", hex $1 /eg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | # XXX: should set utf8 flag too? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | return $decode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 181 | ▶ | sub url_encode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
url_encode: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 181 | my ( $self, $encode ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 181 | ▶ | return () unless defined $encode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 181 | ▶ | if (Encode::is_utf8($encode)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 25 | $encode = Encode::encode_utf8($encode); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | # XXX: Forward slash (and ':') is allowed, for cleaner url. This may break... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | $encode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 181 | =~ s{([^A-Za-z0-9\-_.!~*\'() /:])}{ uc sprintf "%%%02x",ord $1 }eg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 181 | $encode =~ tr/ /+/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 181 | return $encode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | ▶ | sub url_encode_kv { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
url_encode_kv: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | my ($self, $k, $v) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | url_encode($self, $k) . '=' . url_encode($self, $v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 0 | ▶ | sub encode_query { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encode_query: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | my ($self, $param, $sep) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | # require URI; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | # my $url = URI->new('http:'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | # $url->query_form($item->{cf_PARAM}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | # $url->query; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | ▶ | return $param unless ref $param; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | ▶ | join $sep // ';', do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$sep // ";"
MC/DC0%0/1
$sep // ";"
$sep
Truth table0%0/2
A
A= $sep
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | ▶ | if (ref $param eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | url_encode_kv($self, $_, $param->{$_}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | } keys %$param | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 0 | my @param = @$param; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | my @res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 0 | ▶ | while (my ($k, $v) = splice @param, 0, 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 0 | my $ek = url_encode($self, $k); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | push @res, $ek . '='. (url_encode($self, $_) // '') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | ▶ | for ref $v ? @$v : $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
url_encode($self, $_) // ""
MC/DC0%0/1
url_encode($self, $_) // ""
url_encode($self, $_)
Truth table0%0/2
A
A= url_encode($self, $_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | @res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 35 | ▶ | sub callerinfo { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
callerinfo: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 35 | ▶ | my ($pkg, $file, $line) = caller(shift // 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() // 1
MC/DC0%0/1
shift() // 1
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 35 | (file => $file, line => $line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 25 | ▶ | sub ostream { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ostream: called CC=5 SCAR=16.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 25 | ▶ | my $fn = ref $_[0] ? $_[0] : \ ($_[0] //= ""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$_[0] //= ""
MC/DC0%0/1
$_[0] //= ""
$_[0]
Truth table50%1/2
A
A= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 25 | ▶ | open my $fh, '>' . ($_[1] // ''), $fn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$_[1] // ""
MC/DC100%1/1
$_[1] // ""
$_[1]
Truth table100%2/2
A
A= $_[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | or die "Can't create output memory stream: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 25 | $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 10 | ▶ | sub read_file { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_file: called CC=4 SCAR=15.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 10 | my ($fn, $layer) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 10 | my $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 10 | ▶ | if ($fn eq '-') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | $fh = \*STDIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 10 | ▶ | open $fh, '<' . ($layer // ''), $fn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$layer // ""
MC/DC0%0/1
$layer // ""
$layer
Truth table50%1/2
A
A= $layer
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | or die "Can't open '$fn': $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 10 | local $/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 10 | scalar <$fh>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 0 | ▶ | sub dispatch_all { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dispatch_all: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | my ($this, $con, $prefix, $argSpec) = splice @_, 0, 4; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 0 | ▶ | my ($nargs, @preargs) = ref $argSpec ? @$argSpec : $argSpec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 0 | my @queue; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 0 | foreach my $item (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 0 | ▶ | if (ref $item) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 0 | ▶ | print {$con} escape(splice @queue) if @queue; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | my ($wname, @args) = @$item; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 0 | ▶ | my $sub = $this->can('render_' . $prefix . $wname) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | or croak "Can't find widget '$wname' in dispatch"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 0 | ▶ | $sub->($this, $con, @preargs, splice(@args, 0, $nargs // 0), \@args); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$nargs // 0
MC/DC0%0/1
$nargs // 0
$nargs
Truth table0%0/2
A
A= $nargs
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 0 | push @queue, $item; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 0 | ▶ | print {$con} escape(@queue) if @queue; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | ▶ | sub dispatch_one { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dispatch_one: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | my ($this, $con, $prefix, $nargs, $item) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | ▶ | if (ref $item) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | my ($wname, @args) = @$item; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 0 | ▶ | my $sub = $this->can('render_' . $prefix . $wname) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | or croak "Can't find widget '$wname' in dispatch"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | ▶ | $sub->($this, $con, splice(@args, 0, $nargs // 0), \@args); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$nargs // 0
MC/DC0%0/1
$nargs // 0
$nargs
Truth table0%0/2
A
A= $nargs
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | print {$con} escape($item); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 2 | ▶ | sub con_error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
con_error: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 2 | my ($con, $err, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 2 | ▶ | if ($con->can("raise") and my $sub = $con->can("error")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$con->can("raise") and my $sub = $con->can("error")
MC/DC50%1/2
$con->can("raise") and my $sub = $con->can("error")
$con->can("raise")
my $sub = $con->can("error")
Truth table66%2/3
A and B
A= $con->can("raise")B= my $sub = $con->can("error")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 1 | $sub->($con, $err, @args) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 1 | sprintf $err, @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 11 | ▶ | sub safe_render { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
safe_render: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 11 | my ($this, $con, $wspec, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 11 | my @nsegs = lexpand($wspec); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 11 | ▶ | my $wname = join _ => map {defined $_ ? $_ : ''} @nsegs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 11 | ▶ | my $sub = $this->can("render_$wname") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | or die con_error($con, "Can't find widget '%s'", $wname); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 9 | $sub->($this, $con, @args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 33 | ▶ | sub mk_http_status { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mk_http_status: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 33 | my ($code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 33 | require HTTP::Status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 33 | my $message = HTTP::Status::status_message($code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 33 | "Status: $code $message\015\012"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 3500 | ▶ | sub list_isa { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_isa: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 3500 | my ($pack, $all) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 3500 | my $symtab = symtab($pack); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 3500 | ▶ | my $sym = $symtab->{ISA} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 3340 | ▶ | my $isa = *{$sym}{ARRAY} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 3340 | ▶ | return @$isa unless $all; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 73 | [$_, list_isa($_, $all)]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | } @$isa; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 1037 | ▶ | sub set_inc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_inc: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 1037 | my ($pkg, $val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 1037 | $pkg =~ s|::|/|g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 1037 | ▶ | $INC{$pkg.'.pm'} = $val || 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$val || 1
MC/DC0%0/1
$val || 1
$val
Truth table50%1/2
A
A= $val
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | # $INC{$pkg.'.pmc'} = $val || 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 1037 | $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 1702 | ▶ | sub try_invoke { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
try_invoke: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 1702 | my $obj = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 1702 | my ($method, @args) = lexpand(shift); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 1702 | my $default = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 1702 | ▶ | if (defined $obj | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $obj and my $sub = UNIVERSAL::can($obj, $method)
MC/DC50%1/2
defined $obj and my $sub = UNIVERSAL::can($obj, $method)
defined $obj
my $sub = UNIVERSAL::can($obj, $method)
Truth table66%2/3
A and B
A= defined $objB= my $sub = UNIVERSAL::can($obj, $method)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | and my $sub = UNIVERSAL::can($obj, $method)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 1565 | $sub->($obj, @args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 137 | ▶ | wantarray ? () : $default; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | ▶ | sub NIMPL { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
NIMPL: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | ▶ | my ($pack, $file, $line, $sub, $hasargs) = caller($_[0] // 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_[0] // 1
MC/DC0%0/1
$_[0] // 1
$_[0]
Truth table0%0/2
A
A= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | croak "Not implemented call of '$sub'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 4 | ▶ | sub shallow_copy { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
shallow_copy: called CC=5 SCAR=16.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 4 | ▶ | if (ref $_[0] eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 2 | +{%{$_[0]}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | } elsif (ref $_[0] eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 1 | +[@{$_[0]}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | } elsif (not ref $_[0]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | my $copy = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | } elsif ($_[1]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | # Pass thru unknown refs if 2nd arg is true. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 1 | $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 0 | croak "Unsupported data type for shallow_copy: " . ref $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 35 | ▶ | sub deep_copy_array { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deep_copy_array: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | [map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 213 | ▶ | if (ref $_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 23 | deep_copy_array($_) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 190 | $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 35 | } @{$_[0]}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 0 | ▶ | if (not is_debugging() or catch {require Sub::Name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.7
Branch: 1 branch
Condition33%1/3
not is_debugging() or &catch(sub {
require Sub::Name;
}
)
MC/DC0%0/2
not is_debugging() or &catch(sub {
require Sub::Name;
}
)
not is_debugging()
&catch(sub {
require Sub::Name;
}
)
Truth table33%1/3
not(A) or B
A= not is_debugging()B= &catch(sub {
require Sub::Name;
}
)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 1863 | ▶ | *subname = sub { my ($name, $sub) = @_; $sub } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 72 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 0 | *subname = *Sub::Name::subname; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 95 | ▶ | sub incr_opt { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
incr_opt: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 95 | my ($key, $list) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 95 | my $hash = do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 95 | ▶ | if (@$list and defined $list->[0] and ref $list->[0] eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
@$list and defined $list->[0] and ref $list->[0] eq "HASH"
@$list and defined $list->[0]
MC/DC66%2/3
@$list and defined $list->[0] and ref $list->[0] eq "HASH"
@$list
defined $list->[0]
ref $list->[0] eq "HASH"
Truth table75%3/4
A and B and C
A= @$listB= defined $list->[0]C= ref $list->[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 79 | shift @$list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | +{} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 16 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 95 | $hash->{$key}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 95 | $hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 0 | ▶ | sub num_is_ge { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
num_is_ge: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | ▶ | defined $_[0] and not ref $_[0] and $_[0] ne '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
defined $_[0] and not ref $_[0] and $_[0] ne "" and $_[0] =~ /^\d+$/
defined $_[0] and not ref $_[0] and $_[0] ne ""
defined $_[0] and not ref $_[0]
MC/DC0%0/4
defined $_[0] and not ref $_[0] and $_[0] ne "" and $_[0] =~ /^\d+$/
defined $_[0]
not ref $_[0]
$_[0] ne ""
$_[0] =~ /^\d+$/
Truth table0%0/5
A and not(B) and C and D
A= defined $_[0]B= not ref $_[0]C= $_[0] ne ""D= $_[0] =~ /^\d+$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | and $_[0] =~ /^\d+$/ and $& >= $_[1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | # Order preserving unique. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 14 | ▶ | sub unique (@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unique: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 14 | my %dup; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 14 | ▶ | map {$dup{$_}++ ? () : $_} @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 28 | ▶ | sub secure_text_plain { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
secure_text_plain: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 28 | shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 28 | ("Content-type" => "text/plain; charset=utf-8" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | , "X-Content-Type-Options" => "nosniff" # To protect IE8~ from XSS. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | # Just a wrapper (and hook) for die. $self is ignored. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 9 | ▶ | sub raise_response { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
raise_response: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 9 | my ($self, $response) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 9 | die $response; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | # $this->raise_download($fileName, $bytesOrBytesRef, ?[@header]?) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 0 | ▶ | sub raise_download { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
raise_download: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 0 | my $this = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 0 | my $filename = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 0 | ▶ | my $bytesRef = ref $_[2] eq 'SCALAR' ? $_[2] : \$_[2]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 0 | my @header = ("Content-type" => qq{application/octet-stream}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | , "Content-Length" => length($$bytesRef)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 0 | ▶ | push @header, "Content-Disposition" => qq{attachment; filename="$filename"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $filename and $filename ne ""
MC/DC0%0/2
defined $filename and $filename ne ""
defined $filename
$filename ne ""
Truth table0%0/3
A and B
A= defined $filenameB= $filename ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | if defined $filename and $filename ne ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 0 | ▶ | if (defined $_[3] and ref $_[3]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $_[3] and ref $_[3]
MC/DC0%0/2
defined $_[3] and ref $_[3]
defined $_[3]
ref $_[3]
Truth table0%0/3
A and B
A= defined $_[3]B= ref $_[3]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 0 | push @header, lexpand($_[3]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 0 | $this->raise_response([200, \@header, [$$bytesRef]]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 72 | foreach my $what (qw(error text dump)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 216 | my $actual = "psgi_$what"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 216 | my $sub = __PACKAGE__->can($actual); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 216 | my $method = "raise_$actual"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 216 | ▶ | *{globref($method)} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 2 | $self->raise_response($sub->($self, @_)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | 216 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 6 | ▶ | sub psgi_error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
psgi_error: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 6 | my ($self, $status, $msg, @rest) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 6 | my $escaped = escape($msg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | 6 | Encode::_utf8_off($escaped); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 6 | ▶ | return [$status, [$self->secure_text_plain, @rest] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | , [$escaped | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | , $msg =~ /\n\z/ ? () : "\n" ]]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 21 | ▶ | sub psgi_text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
psgi_text: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | 21 | my ($self, $statusAndHeader, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 21 | ▶ | my ($status, @header) = ref $statusAndHeader ? @$statusAndHeader : $statusAndHeader; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 21 | return [$status, [$self->secure_text_plain, @header], \@args]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 1 | ▶ | sub psgi_dump { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
psgi_dump: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | [200 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | , [$self->secure_text_plain] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | 1 | , [join("\n", map {terse_dump($_)} @_)."\n"]]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | 0 | ▶ | sub dumpout (@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dumpout: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | 0 | __PACKAGE__->raise_psgi_dump(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | 593 | ▶ | sub ixhash { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ixhash: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | 593 | tie my %hash, 'Tie::IxHash', @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | 593 | \%hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | # Ported from: Rack::Utils.parse_nested_query | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 420 | ▶ | sub parse_nested_query { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_nested_query: called CC=11 SCAR=24.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | 420 | ▶ | return {} unless defined $_[0] and $_[0] ne ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $_[0] and $_[0] ne ""
MC/DC50%1/2
defined $_[0] and $_[0] ne ""
defined $_[0]
$_[0] ne ""
Truth table66%2/3
A and B
A= defined $_[0]B= $_[0] ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | 404 | my ($enc) = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | 404 | ▶ | my $params = $_[2] // ixhash(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$_[2] // ixhash()
MC/DC0%0/2
$_[2] // ixhash()
$_[2]
ixhash()
Truth table33%1/3
A // B
A= $_[2]B= ixhash()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | 404 | ▶ | if (ref $_[0]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | 355 | ▶ | my @pairs = map {$enc ? map(Encode::decode($enc, $_), @$_) : @$_} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | 355 | ref $_[0] eq 'ARRAY' ? $_[0] : [%{$_[0]}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | 355 | ▶ | while (my ($k, $v) = splice @pairs, 0, 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 156 | normalize_params($params, $k, $v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 49 | foreach my $p (split /[;&]/, $_[0]) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | my ($k, $v) = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | 97 | s/\+/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 186 | my $raw = URI::Escape::uri_unescape($_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | 186 | ▶ | $enc ? Encode::decode($enc, $raw) : $raw; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | } split /=/, $p, 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 97 | ▶ | normalize_params($params, $k, $v) if defined $k; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | 401 | $params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | 375 | ▶ | sub normalize_params { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
normalize_params: called CC=20 SCAR=30.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | 375 | my ($params, $name, $v) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | 375 | ▶ | if ($name eq '[]' and defined $v) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$name eq "[]" and defined $v
MC/DC50%1/2
$name eq "[]" and defined $v
$name eq "[]"
defined $v
Truth table66%2/3
A and B
A= $name eq "[]"B= defined $v
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | 1 | return [$v]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 374 | ▶ | my ($k) = $name =~ m(\A[\[\]]*([^\[\]]+)\]*) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 372 | my $after = substr($name, length $&); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | 372 | ▶ | if ($after eq '') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 190 | $params->{$k} = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | } elsif ($after eq "[]") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | 56 | ▶ | my $item = $params->{$k} //= []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$params->{$k} //= []
MC/DC100%1/1
$params->{$k} //= []
$params->{$k}
Truth table100%2/2
A
A= $params->{$k}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | 56 | ▶ | croak "expected ARRAY (got ".(ref $item || 'String').") for param `$k'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
ref $item || 'String'
MC/DC0%0/1
ref $item || 'String'
ref $item
Truth table50%1/2
A
A= ref $item
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | unless ref $item eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | 55 | push @$item, $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | ▶ | } elsif ($after =~ m(^\[\]\[([^\[\]]+)\]$) or $after =~ m(^\[\](.+)$)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$after =~ /^\[\]\[([^\[\]]+)\]$/ or $after =~ /^\[\](.+)$/
MC/DC100%2/2
$after =~ /^\[\]\[([^\[\]]+)\]$/ or $after =~ /^\[\](.+)$/
$after =~ /^\[\]\[([^\[\]]+)\]$/
$after =~ /^\[\](.+)$/
Truth table100%3/3
A or B
A= $after =~ /^\[\]\[([^\[\]]+)\]$/B= $after =~ /^\[\](.+)$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 41 | my $child_key = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | 41 | ▶ | my $item = $params->{$k} //= []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$params->{$k} //= []
MC/DC100%1/1
$params->{$k} //= []
$params->{$k}
Truth table100%2/2
A
A= $params->{$k}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | 41 | ▶ | croak "expected ARRAY (got ".(ref $item || 'String').") for param `$k'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
ref $item || 'String'
MC/DC0%0/1
ref $item || 'String'
ref $item
Truth table50%1/2
A
A= ref $item
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | unless ref $item eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | 40 | ▶ | if (@$item and ref $item->[-1] eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
@$item and ref $item->[-1] eq "HASH" and not exists $item->[-1]{$child_key}
@$item and ref $item->[-1] eq "HASH"
MC/DC100%3/3
@$item and ref $item->[-1] eq "HASH" and not exists $item->[-1]{$child_key}
@$item
ref $item->[-1] eq "HASH"
not exists $item->[-1]{$child_key}
Truth table100%4/4
A and B and not(C)
A= @$itemB= ref $item->[-1] eq "HASH"C= not exists $item->[-1]{$child_key}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | and not exists $item->[-1]->{$child_key}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | 12 | normalize_params($item->[-1], $child_key, $v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | 28 | push @$item, normalize_params(ixhash(), $child_key, $v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 85 | ▶ | my $item = $params->{$k} //= ixhash(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$params->{$k} //= ixhash()
MC/DC0%0/2
$params->{$k} //= ixhash()
$params->{$k}
ixhash()
Truth table66%2/3
A //= B
A= $params->{$k}B= ixhash()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | 85 | ▶ | croak "expected HASH (got ".(ref $item || 'String').") for param `$k'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
ref $item || 'String'
MC/DC0%0/1
ref $item || 'String'
ref $item
Truth table50%1/2
A
A= ref $item
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | unless ref $item eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | 84 | $params->{$k} = normalize_params($item, $after, $v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 367 | $params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | # Ported (with API modification) from: Rack::Utils.build_nested_query | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 52 | ▶ | sub build_nested_query { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_nested_query: called CC=5 SCAR=17.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | 52 | my ($self, $hash, $opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | my $ignore = ref $opts->{ignore} eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | ? $opts->{ignore} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | 52 | ▶ | : +{map {$_ => 1} @{$opts->{ignore}}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | join $opts->{sep} // '&' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | , map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | 52 | ▶ | if ($ignore and $ignore->{$_}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
$opts->{"sep"} // "&"
$ignore and $ignore->{$_}
MC/DC100%1/1
$opts->{"sep"} // "&"
$opts->{"sep"}
MC/DC0%0/2
$ignore and $ignore->{$_}
$ignore
$ignore->{$_}
Truth table100%2/2
A
A= $opts->{"sep"}
Truth table33%1/3
A and B
A= $ignoreB= $ignore->{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | () | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | 0 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | 69 | my $v = $hash->{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | 69 | my $k = url_encode($self, $_); # URI::Escape::uri_escape does too much. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | 69 | $k =~ tr/ /+/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | 69 | build_nested_query_value($self, $v, $k); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | } keys %$hash; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | 183 | ▶ | sub build_nested_query_value { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_nested_query_value: called CC=7 SCAR=19.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 183 | my ($self, $value, $prefix) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | 183 | ▶ | if (not defined $value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | 4 | $prefix; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | } elsif (ref $value eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | 39 | build_nested_query_value($self, $_, $prefix."[]"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | } @$value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | ▶ | } elsif (ref $value eq 'HASH' or UNIVERSAL::can($value, 'keys')) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
ref $value eq "HASH" or UNIVERSAL::can($value, "keys")
MC/DC50%1/2
ref $value eq "HASH" or UNIVERSAL::can($value, "keys")
ref $value eq "HASH"
UNIVERSAL::can($value, "keys")
Truth table66%2/3
A or B
A= ref $value eq "HASH"B= UNIVERSAL::can($value, "keys")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | 50 | my $escaped = URI::Escape::uri_escape_utf8($_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 56 | ▶ | my $key = $prefix ? $prefix."[$escaped]" : $escaped; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | 56 | $key =~ tr/ /+/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | 56 | build_nested_query_value($self, $value->{$_}, $key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | } keys %$value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | } elsif (not defined $prefix) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | 0 | Carp::croak "value must be a Hash: ". terse_dump($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | 90 | $prefix."=".URI::Escape::uri_escape_utf8($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | 909 | ▶ | sub pkg2pm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pkg2pm: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | 909 | my ($pack) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | 909 | $pack =~ s{::|'}{/}g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | 909 | "$pack.pm"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | 0 | ▶ | sub dputs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dputs: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | 0 | (undef, undef, my $line) = caller(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 0 | (undef, undef, undef, my $func) = caller(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | print STDERR "# $func $line: ", (map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | 0 | ▶ | if (defined $_ and not ref $_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $_ and not ref $_
MC/DC0%0/2
defined $_ and not ref $_
defined $_
not ref $_
Truth table0%0/3
A and not(B)
A= defined $_B= not ref $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | 0 | $_ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | 0 | terse_dump($_) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | } @_), "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 25 | ▶ | sub is_done { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_done: called CC=4 SCAR=14.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | 6 | defined $_[0] and ref $_[0] eq 'SCALAR' and not ref ${$_[0]} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | 25 | ▶ | and ${$_[0]} eq 'DONE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
defined $_[0] and ref $_[0] eq "SCALAR" and not ref ${$_[0];}
defined $_[0] and ref $_[0] eq "SCALAR"
MC/DC33%1/3
defined $_[0] and ref $_[0] eq "SCALAR" and not ref ${$_[0];}
defined $_[0]
ref $_[0] eq "SCALAR"
not ref ${$_[0];}
Truth table50%2/4
A and B and not(C)
A= defined $_[0]B= ref $_[0] eq "SCALAR"C= not ref ${$_[0];}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 6 | ▶ | sub rewind { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rewind: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | 6 | ▶ | if ($_[0]->can("rewind")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 0 | $_[0]->rewind | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | 6 | seek $_[0], 0, 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | 6 | truncate $_[0], 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | 0 | ▶ | sub merge_hash_renaming (&@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge_hash_renaming: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 0 | my ($code, $base, @overlay) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | 0 | my $result = +{%$base}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | 0 | foreach my $hash (@overlay) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | 0 | local $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | 0 | foreach (keys %$hash) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | 0 | ▶ | if ($code) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 0 | ▶ | my ($renamed) = $code->($_) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | 0 | $result->{$renamed} = $hash->{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 0 | $result->{$_} = $hash->{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | 0 | $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | 14 | ▶ | sub trimleft_length { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trimleft_length: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | 14 | shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 14 | ▶ | return $_[0] unless length $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | 7 | substr($_[0], length($_[1])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | 1 | ▶ | sub reencode_malformed_utf8 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reencode_malformed_utf8: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | 1 | my ($str, $fallback_flag) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | 1 | Encode::_utf8_off($str); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | 1 | ▶ | my $bytes = Encode::decode_utf8($str, $fallback_flag // Encode::FB_XMLCREF); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$fallback_flag // 1032
MC/DC0%0/1
$fallback_flag // 1032
$fallback_flag
Truth table50%1/2
A
A= $fallback_flag
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | 1 | Encode::_utf8_on($bytes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | 1 | $bytes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | 2 | ▶ | sub get_entity_symbol { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_entity_symbol: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | 2 | my ($pack, $entns, $entity_name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | 2 | my $symbol_name = join("_", entity => $entity_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | 2 | look_for_globref($entns, $symbol_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | 7 | ▶ | sub maybe_findbin_bin { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
maybe_findbin_bin: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | 7 | ▶ | my $symtab = $main::{'FindBin::'} or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | 7 | ▶ | my $globref = $ {*{$symtab}{HASH}}{Bin} or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | 7 | $ {*{$globref}{SCALAR}} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | # to put all functions into @EXPORT_OK. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | 72 | our @EXPORT_OK = qw(define_const); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | 72 | my $symtab = symtab(__PACKAGE__); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | 72 | foreach my $name (grep {/^[a-z]/} keys %$symtab) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | 7632 | my $glob = $symtab->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | 7632 | ▶ | next unless *{$glob}{CODE}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | 7128 | push @EXPORT_OK, $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | 72 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||