| 1 | package Template::Alloy::VMethod; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | Template::Alloy::VMethod - VMethod role. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 10 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 10 | ▶ | use Template::Alloy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 10 | ▶ | use base qw(Exporter); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 10 | our @EXPORT_OK = qw(define_vmethod | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | $ITEM_OPS $ITEM_METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | $SCALAR_OPS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | $LIST_OPS $LIST_METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | $HASH_OPS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | $FILTER_OPS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | $VOBJS); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | sub new { die "This class is a role for use by packages such as Template::Alloy" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 10 | our ($JSON, $JSONP); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub json { $JSON ||= do { require JSON; JSON->new->utf8->allow_nonref->allow_unknown->allow_blessed->convert_blessed->canonical } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
json: not called CC=2 SCAR=17.9
Pod
documented
Condition0%0/3
$Template::Alloy::VMethod::JSON ||= do {
require JSON;
"JSON"->new->utf8->allow_nonref->allow_unknown->allow_blessed->convert_blessed->canonical
}
MC/DC0%0/2
$Template::Alloy::VMethod::JSON ||= do {
require JSON;
"JSON"->new->utf8->allow_nonref->allow_unknown->allow_blessed->convert_blessed->canonical
}
$Template::Alloy::VMethod::JSON
do {
require JSON;
"JSON"->new->utf8->allow_nonref->allow_unknown->allow_blessed->convert_blessed->canonical
}
Truth table0%0/3
A ||= B
A= $Template::Alloy::VMethod::JSONB= do {
require JSON;
"JSON"->new->utf8->allow_nonref->allow_unknown->allow_blessed->convert_blessed->canonical
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub jsonp { $JSONP ||= do { require JSON; JSON->new->utf8->allow_nonref->allow_unknown->allow_blessed->convert_blessed->canonical->pretty } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
jsonp: not called CC=2 SCAR=17.9
Pod
undocumented
Condition0%0/3
$Template::Alloy::VMethod::JSONP ||= do {
require JSON;
"JSON"->new->utf8->allow_nonref->allow_unknown->allow_blessed->convert_blessed->canonical->pretty
}
MC/DC0%0/2
$Template::Alloy::VMethod::JSONP ||= do {
require JSON;
"JSON"->new->utf8->allow_nonref->allow_unknown->allow_blessed->convert_blessed->canonical->pretty
}
$Template::Alloy::VMethod::JSONP
do {
require JSON;
"JSON"->new->utf8->allow_nonref->allow_unknown->allow_blessed->convert_blessed->canonical->pretty
}
Truth table0%0/3
A ||= B
A= $Template::Alloy::VMethod::JSONPB= do {
require JSON;
"JSON"->new->utf8->allow_nonref->allow_unknown->allow_blessed->convert_blessed->canonical->pretty
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | our $SCALAR_OPS = our $ITEM_OPS = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 10 | ▶ | '0' => sub { $_[0] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 10 | ▶ | abs => sub { no warnings; abs shift }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 10 | ▶ | atan2 => sub { no warnings; atan2($_[0], $_[1]) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | chunk => \&vmethod_chunk, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 66 | ▶ | collapse => sub { local $_ = $_[0]; s/^\s+//; s/\s+$//; s/\s+/ /g; $_ }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 10 | ▶ | cos => sub { no warnings; cos $_[0] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 6 | ▶ | defined => sub { defined $_[0] ? 1 : '' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 3 | ▶ | dquote => sub { local $_ = $_[0]; return if ! $_; s/([\"\\])/\\$1/g; s/\n/\\n/g; $_ }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 10 | ▶ | exp => sub { no warnings; exp $_[0] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | fmt => \&vmethod_fmt_scalar, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 'format' => \&vmethod_format, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | hash => sub { {value => $_[0]} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 10 | ▶ | hex => sub { no warnings; hex $_[0] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 50 | ▶ | html => sub { local $_ = $_[0]; return $_ if ! $_; s/&/&/g; s/</</g; s/>/>/g; s/\"/"/g; $_ }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | indent => \&vmethod_indent, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 10 | ▶ | int => sub { no warnings; int $_[0] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 3 | ▶ | item => sub { $_[0] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 2 | ▶ | js => sub { local $_ = $_[0]; return if ! $_; s/\n/\\n/g; s/\r/\\r/g; s/(?<!\\)([\"\'])/\\$1/g; $_ }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | json => sub { return json()->encode($_[0]) if ! $_[1]; my $j = jsonp()->encode($_[0]); chomp $j; $j }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 3 | ▶ | lc => sub { lc $_[0] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 3 | ▶ | lcfirst => sub { lcfirst $_[0] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 42 | ▶ | length => sub { defined($_[0]) ? length($_[0]) : 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 3 | ▶ | list => sub { [$_[0]] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 10 | ▶ | log => sub { no warnings; log $_[0] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 3 | ▶ | lower => sub { lc $_[0] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | match => \&vmethod_match, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 3 | ▶ | new => sub { defined $_[0] ? $_[0] : '' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 13 | ▶ | none => sub { $_[0] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 3 | ▶ | null => sub { '' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 10 | ▶ | oct => sub { no warnings; oct $_[0] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | print => sub { no warnings; "@_" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
Subroutine
__ANON__: not called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 10 | ▶ | rand => sub { no warnings; rand shift }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 6 | ▶ | remove => sub { vmethod_replace(shift, shift, '', 1) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | repeat => \&vmethod_repeat, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | replace => \&vmethod_replace, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 'return' => \&vmethod_return, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 6 | ▶ | search => sub { my ($str, $pat) = @_; return $str if ! defined $str || ! defined $pat; return $str =~ /$pat/ }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.5
Branch: 1 branch
Condition33%1/3
defined $str and defined $pat
MC/DC0%0/2
defined $str and defined $pat
defined $str
defined $pat
Truth table33%1/3
A and B
A= defined $strB= defined $pat
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 10 | ▶ | sin => sub { no warnings; sin $_[0] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 6 | ▶ | size => sub { 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | split => \&vmethod_split, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 10 | ▶ | sprintf => sub { no warnings; my $pat = shift; sprintf($pat, @_) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 10 | ▶ | sqrt => sub { no warnings; sqrt $_[0] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 3 | ▶ | squote => sub { local $_ = $_[0]; return if ! $_; s/([\'\\])/\\$1/g; $_ }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 10 | ▶ | srand => sub { no warnings; srand $_[0]; '' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 3 | ▶ | stderr => sub { print STDERR $_[0]; '' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | substr => \&vmethod_substr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 3 | ▶ | trim => sub { local $_ = $_[0]; s/^\s+//; s/\s+$//; $_ }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 3 | ▶ | uc => sub { uc $_[0] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 3 | ▶ | ucfirst => sub { ucfirst $_[0] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 3 | ▶ | upper => sub { uc $_[0] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | uri => \&vmethod_uri, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | url => \&vmethod_url, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 12 | ▶ | xml => sub { local $_ = $_[0]; s/&/&/g; s/</</g; s/>/>/g; s/\"/"/g; s/\'/'/g; $_ }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 10 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | our $ITEM_METHODS = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | eval => \&Template::Alloy::item_method_eval, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | evaltt => \&Template::Alloy::item_method_eval, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | file => \&item_method_redirect, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | redirect => \&item_method_redirect, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | block_exists => sub { defined($_[1]) && UNIVERSAL::isa($_[0], 'HASH') && $_[0]->{'BLOCKS'} && exists($_[0]->{'BLOCKS'}->{$_[1]}) || 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
Branch: 1 branch
Condition0%0/9
defined $_[1] and UNIVERSAL::isa($_[0], "HASH") and $_[0]{"BLOCKS"} and exists $_[0]{"BLOCKS"}{$_[1]}
defined $_[1] and UNIVERSAL::isa($_[0], "HASH") and $_[0]{"BLOCKS"}
defined $_[1] and UNIVERSAL::isa($_[0], "HASH")
MC/DC0%0/4
defined $_[1] and UNIVERSAL::isa($_[0], "HASH") and $_[0]{"BLOCKS"} and exists $_[0]{"BLOCKS"}{$_[1]}
defined $_[1]
UNIVERSAL::isa($_[0], "HASH")
$_[0]{"BLOCKS"}
exists $_[0]{"BLOCKS"}{$_[1]}
Truth table0%0/5
A and B and C and D
A= defined $_[1]B= UNIVERSAL::isa($_[0], "HASH")C= $_[0]{"BLOCKS"}D= exists $_[0]{"BLOCKS"}{$_[1]}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 10 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 10 | our $FILTER_OPS = {}; # generally - non-dynamic filters belong in scalar ops | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | our $LIST_OPS = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 9 | ▶ | defined => sub { return 1 if @_ == 1; defined $_[0]->[ defined($_[1]) ? $_[1] : 0 ] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.1
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 6 | ▶ | first => sub { my ($ref, $i) = @_; return $ref->[0] if ! $i; return [@{$ref}[0 .. $i - 1]]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | fmt => \&vmethod_fmt_list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 10 | ▶ | grep => sub { no warnings; my ($ref, $pat) = @_; UNIVERSAL::isa($pat, 'CODE') ? [grep {$pat->($_)} @$ref] : [grep {/$pat/} @$ref] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 10 | ▶ | hash => sub { no warnings; my $list = shift; return {@$list} if ! @_; my $i = shift || 0; return {map {$i++ => $_} @$list} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=3 SCAR=11.0
Branch: 1 branch
Condition50%1/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 6 | ▶ | import => sub { my $ref = shift; push @$ref, grep {defined} map {ref eq 'ARRAY' ? @$_ : undef} @_; '' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 6 | ▶ | item => sub { $_[0]->[ $_[1] || 0 ] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Condition100%2/2
$_[1] || 0
MC/DC100%1/1
$_[1] || 0
$_[1]
Truth table100%2/2
A
A= $_[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 10 | ▶ | join => sub { my ($ref, $join) = @_; $join = ' ' if ! defined $join; no warnings; return join $join, @$ref }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | json => sub { return json()->encode($_[0]) if ! $_[1]; my $j = jsonp()->encode($_[0]); chomp $j; $j }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 6 | ▶ | last => sub { my ($ref, $i) = @_; return $ref->[-1] if ! $i; return [@{$ref}[-$i .. -1]]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 9 | ▶ | list => sub { $_[0] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | map => sub { no warnings; my ($ref, $code) = @_; UNIVERSAL::isa($code, 'CODE') ? [map {$code->($_)} @$ref] : [map {$code} @$ref] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.1
Subroutine
__ANON__: called CC=2 SCAR=7.1
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 10 | ▶ | max => sub { no warnings; $#{ $_[0] } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 9 | ▶ | merge => sub { my $ref = shift; return [ @$ref, grep {defined} map {ref eq 'ARRAY' ? @$_ : undef} @_ ] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 10 | ▶ | new => sub { no warnings; return [@_] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 3 | ▶ | null => sub { '' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | nsort => \&vmethod_nsort, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | pick => \&vmethod_pick, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 3 | ▶ | pop => sub { pop @{ $_[0] } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 3 | ▶ | push => sub { my $ref = shift; push @$ref, @_; return '' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 'return' => \&vmethod_return, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 9 | ▶ | reverse => sub { [ reverse @{ $_[0] } ] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 3 | ▶ | shift => sub { shift @{ $_[0] } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 10 | ▶ | size => sub { no warnings; scalar @{ $_[0] } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 9 | ▶ | slice => sub { my ($ref, $a, $b) = @_; $a ||= 0; $b = $#$ref if ! defined $b; return [@{$ref}[$a .. $b]] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
Branch: 1 branch
Condition100%2/2
$a ||= 0
MC/DC100%1/1
$a ||= 0
$a
Truth table100%2/2
A
A= $a
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | sort => \&vmethod_sort, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | splice => \&vmethod_splice, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 3 | ▶ | unique => sub { my %u; return [ grep { ! $u{$_}++ } @{ $_[0] } ] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 3 | ▶ | unshift => sub { my $ref = shift; unshift @$ref, @_; return '' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 10 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 10 | our $LIST_METHODS = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | our $HASH_OPS = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 12 | ▶ | defined => sub { return 1 if @_ == 1; defined $_[0]->{ defined($_[1]) ? $_[1] : '' } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.1
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 9 | ▶ | delete => sub { my $h = shift; delete @{ $h }{map {defined($_) ? $_ : ''} @_}; '' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 6 | ▶ | each => sub { [%{ $_[0] }] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 9 | ▶ | exists => sub { exists $_[0]->{ defined($_[1]) ? $_[1] : '' } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | fmt => \&vmethod_fmt_hash, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 9 | ▶ | hash => sub { $_[0] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 6 | ▶ | import => sub { my ($a, $b) = @_; @{$a}{keys %$b} = values %$b if ref($b) eq 'HASH'; '' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 6 | ▶ | item => sub { my ($h, $k) = @_; $k = '' if ! defined $k; $Template::Alloy::QR_PRIVATE && $k =~ $Template::Alloy::QR_PRIVATE ? undef : $h->{$k} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.2
Branch: 2 branches
Condition66%2/3
$Template::Alloy::QR_PRIVATE and $k =~ /$Template::Alloy::QR_PRIVATE/
MC/DC50%1/2
$Template::Alloy::QR_PRIVATE and $k =~ /$Template::Alloy::QR_PRIVATE/
$Template::Alloy::QR_PRIVATE
$k =~ /$Template::Alloy::QR_PRIVATE/
Truth table66%2/3
A and B
A= $Template::Alloy::QR_PRIVATEB= $k =~ /$Template::Alloy::QR_PRIVATE/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 24 | ▶ | items => sub { [ %{ $_[0] } ] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | json => sub { return json()->encode($_[0]) if ! $_[1]; my $j = jsonp()->encode($_[0]); chomp $j; $j }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 18 | ▶ | keys => sub { [keys %{ $_[0] }] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | list => \&vmethod_list_hash, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 10 | ▶ | new => sub { no warnings; return (@_ == 1 && ref $_[-1] eq 'HASH') ? $_[-1] : {@_} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=3 SCAR=11.0
Branch: 1 branch
Condition66%2/3
@_ == 1 and ref $_[-1] eq "HASH"
MC/DC50%1/2
@_ == 1 and ref $_[-1] eq "HASH"
@_ == 1
ref $_[-1] eq "HASH"
Truth table66%2/3
A and B
A= @_ == 1B= ref $_[-1] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 3 | ▶ | null => sub { '' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 3 | ▶ | nsort => sub { my $ref = shift; [sort { $ref->{$a} <=> $ref->{$b}} keys %$ref] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 6 | ▶ | pairs => sub { [map { {key => $_, value => $_[0]->{$_}} } sort keys %{ $_[0] } ] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 'return' => \&vmethod_return, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 12 | ▶ | size => sub { scalar keys %{ $_[0] } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 3 | ▶ | sort => sub { my $ref = shift; [sort {lc $ref->{$a} cmp lc $ref->{$b}} keys %$ref] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 6 | ▶ | values => sub { [values %{ $_[0] }] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 10 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 10 | our $VOBJS = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | Text => $SCALAR_OPS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | List => $LIST_OPS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | Hash => $HASH_OPS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 10 | foreach (values %$VOBJS) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 30 | $_->{'Text'} = $_->{'fmt'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 30 | $_->{'Hash'} = $_->{'hash'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 30 | $_->{'List'} = $_->{'list'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | ### long virtual methods or filters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | ### many of these vmethods have used code from Template/Stash.pm to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | ### assure conformance with the TT spec. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | sub define_vmethod { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
define_vmethod: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my ($self, $type, $name, $sub) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | if ( $type =~ /scalar|item|text/i) { $SCALAR_OPS->{$name} = $sub } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | elsif ($type =~ /array|list/i ) { $LIST_OPS->{ $name} = $sub } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | elsif ($type =~ /hash/i ) { $HASH_OPS->{ $name} = $sub } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | elsif ($type =~ /filter/i ) { $FILTER_OPS->{$name} = $sub } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | else { die "Invalid type vmethod type $type" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 96 | ▶ | sub vmethod_fmt_scalar { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vmethod_fmt_scalar: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 96 | ▶ | my $str = shift; $str = '' if ! defined $str; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 96 | ▶ | my $pat = shift; $pat = '%s' if ! defined $pat; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 10 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 96 | ▶ | return @_ ? sprintf($pat, $_[0], $str) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | : sprintf($pat, $str); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 27 | ▶ | sub vmethod_fmt_list { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vmethod_fmt_list: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 27 | ▶ | my $ref = shift || return ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || (return '')
MC/DC0%0/1
shift() || (return '')
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 27 | ▶ | my $pat = shift; $pat = '%s' if ! defined $pat; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 27 | ▶ | my $sep = shift; $sep = ' ' if ! defined $sep; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 10 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 12 | return @_ ? join($sep, map {sprintf $pat, $_[0], $_} @$ref) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 27 | ▶ | : join($sep, map {sprintf $pat, $_} @$ref); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 30 | ▶ | sub vmethod_fmt_hash { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vmethod_fmt_hash: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 30 | ▶ | my $ref = shift || return ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || (return '')
MC/DC0%0/1
shift() || (return '')
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 30 | ▶ | my $pat = shift; $pat = "%s\t%s" if ! defined $pat; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 30 | ▶ | my $sep = shift; $sep = "\n" if ! defined $sep; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 10 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 42 | ▶ | return ! @_ ? join($sep, map {sprintf $pat, $_, $ref->{$_}} sort keys %$ref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 6 | : @_ == 1 ? join($sep, map {sprintf $pat, $_[0], $_, $ref->{$_}} sort keys %$ref) # don't get to pick - it applies to the key | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 30 | ▶ | : join($sep, map {sprintf $pat, $_[0], $_, $_[1], $ref->{$_}} sort keys %$ref); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 6 | ▶ | sub vmethod_chunk { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vmethod_chunk: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 6 | my $str = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 6 | ▶ | my $size = shift || 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || 1
MC/DC0%0/1
shift() || 1
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 6 | my @list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 6 | ▶ | if ($size < 0) { # chunk from the opposite end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 3 | $str = reverse $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 3 | $size = -$size; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 3 | ▶ | unshift(@list, scalar reverse $1) while $str =~ /( .{$size} | .+ )/xg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 3 | ▶ | push(@list, $1) while $str =~ /( .{$size} | .+ )/xg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 6 | return \@list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 12 | ▶ | sub vmethod_indent { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vmethod_indent: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 12 | ▶ | my $str = shift; $str = '' if ! defined $str; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 12 | ▶ | my $pre = shift; $pre = 4 if ! defined $pre; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 12 | ▶ | $pre = ' ' x $pre if $pre =~ /^\d+$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 12 | $str =~ s/^/$pre/mg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 12 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 18 | ▶ | sub vmethod_format { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vmethod_format: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 18 | ▶ | my $str = shift; $str = '' if ! defined $str; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 18 | ▶ | my $pat = shift; $pat = '%s' if ! defined $pat; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 18 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 9 | return join "\n", map{ sprintf $pat, $_[0], $_ } split(/\n/, $str); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 9 | return join "\n", map{ sprintf $pat, $_ } split(/\n/, $str); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 12 | ▶ | sub vmethod_list_hash { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vmethod_list_hash: called CC=3 SCAR=12.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 12 | my ($hash, $what) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 12 | ▶ | $what = 'pairs' if ! $what || $what !~ /^(keys|values|each|pairs)$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$what and $what =~ /^(keys|values|each|pairs)$/
MC/DC0%0/2
$what and $what =~ /^(keys|values|each|pairs)$/
$what
$what =~ /^(keys|values|each|pairs)$/
Truth table33%1/3
A and B
A= $whatB= $what =~ /^(keys|values|each|pairs)$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 12 | return $HASH_OPS->{$what}->($hash); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 39 | ▶ | sub vmethod_match { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vmethod_match: called CC=5 SCAR=16.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 39 | my ($str, $pat, $global) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 39 | ▶ | return [] if ! defined $str || ! defined $pat; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $str and defined $pat
MC/DC0%0/2
defined $str and defined $pat
defined $str
defined $pat
Truth table33%1/3
A and B
A= defined $strB= defined $pat
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 39 | ▶ | my @res = $global ? ($str =~ /$pat/g) : ($str =~ /$pat/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 39 | ▶ | return @res ? \@res : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 6 | ▶ | sub vmethod_nsort { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vmethod_nsort: called CC=4 SCAR=14.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 6 | my ($list, $field) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | return defined($field) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 6 | ▶ | ? [map {$_->[0]} sort {$a->[1] <=> $b->[1]} map {[$_, (ref $_ eq 'HASH' ? $_->{$field} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | : UNIVERSAL::can($_, $field) ? $_->$field() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | : $_)]} @$list ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 6 | ▶ | : [sort {$a <=> $b} @$list]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 9 | ▶ | sub vmethod_pick { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vmethod_pick: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 9 | my $ref = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 10 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 9 | my $n = int(shift); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 9 | ▶ | $n = 1 if $n < 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 9 | my @ind = map { $ref->[ rand @$ref ] } 1 .. $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 9 | ▶ | return $n == 1 ? $ind[0] : \@ind; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 99 | ▶ | sub vmethod_repeat { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vmethod_repeat: called CC=6 SCAR=18.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 99 | my ($str, $n, $join) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 99 | ▶ | return '' if ! defined $str || ! length $str; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $str and length $str
MC/DC0%0/2
defined $str and length $str
defined $str
length $str
Truth table33%1/3
A and B
A= defined $strB= length $str
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 99 | ▶ | $n = 1 if ! defined($n) || ! length $n; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $n and length $n
MC/DC50%1/2
defined $n and length $n
defined $n
length $n
Truth table66%2/3
A and B
A= defined $nB= length $n
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 99 | ▶ | $join = '' if ! defined $join; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 99 | return join $join, ($str) x $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | ### This method is a combination of my submissions along | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | ### with work from Andy Wardley, Sergey Martynoff, Nik Clayton, and Josh Rosenbaum | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 33 | ▶ | sub vmethod_replace { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vmethod_replace: called CC=6 SCAR=18.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 33 | my ($text, $pattern, $replace, $global) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 33 | ▶ | $text = '' unless defined $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 33 | ▶ | $pattern = '' unless defined $pattern; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 33 | ▶ | $replace = '' unless defined $replace; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 33 | ▶ | $global = 1 unless defined $global; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 42 | ▶ | my $expand = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=15.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 42 | my ($chunk, $start, $end) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 42 | $chunk =~ s{ \\(\\|\$) | \$ (\d+) }{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 6 | ▶ | $1 ? $1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$2 > $start->$#* or $2 == 0
MC/DC0%0/2
$2 > $start->$#* or $2 == 0
$2 > $start->$#*
$2 == 0
Truth table33%1/3
A or B
A= $2 > $start->$#*B= $2 == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | : ($2 > $#$start || $2 == 0) ? '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | : substr($text, $start->[$2], $end->[$2] - $start->[$2]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | }exg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 42 | $chunk; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 33 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 33 | ▶ | if ($global) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 30 | $text =~ s{$pattern}{ $expand->($replace, [@-], [@+]) }eg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 3 | $text =~ s{$pattern}{ $expand->($replace, [@-], [@+]) }e; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 33 | return $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | sub vmethod_return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vmethod_return: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | my $obj = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | Template::Alloy->throw('return', {return_val => $obj}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 48 | ▶ | sub vmethod_sort { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vmethod_sort: called CC=5 SCAR=16.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 48 | my ($list, $field) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 48 | ▶ | if (! defined $field) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 42 | return [map {$_->[0]} sort {$a->[1] cmp $b->[1]} map {[$_, lc $_]} @$list ]; # case insensitive | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } elsif (UNIVERSAL::isa($field, 'CODE')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 3 | return [sort {int($field->($a, $b))} @$list]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 3 | ▶ | return [map {$_->[0]} sort {$a->[1] cmp $b->[1]} map {[$_, lc(ref $_ eq 'HASH' ? $_->{$field} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | : UNIVERSAL::can($_, $field) ? $_->$field() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | : $_)]} @$list ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 12 | ▶ | sub vmethod_splice { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vmethod_splice: called CC=6 SCAR=18.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 12 | my ($ref, $i, $len, @replace) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | @replace = @{ $replace[0] } if @replace == 1 && ref $replace[0] eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@replace == 1 and ref $replace[0] eq "ARRAY"
MC/DC0%0/2
@replace == 1 and ref $replace[0] eq "ARRAY"
@replace == 1
ref $replace[0] eq "ARRAY"
Truth table66%2/3
A and B
A= @replace == 1B= ref $replace[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 12 | ▶ | if (defined $len) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 6 | ▶ | return [splice @$ref, $i || 0, $len, @replace]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$i || 0
MC/DC0%0/1
$i || 0
$i
Truth table50%1/2
A
A= $i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } elsif (defined $i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 3 | return [splice @$ref, $i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 3 | return [splice @$ref]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 18 | ▶ | sub vmethod_split { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vmethod_split: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 18 | my ($str, $pat, $lim) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 18 | ▶ | $str = '' if ! defined $str; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 18 | ▶ | if (defined $lim) { return defined $pat ? [split $pat, $str, $lim] : [split ' ', $str, $lim] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 12 | ▶ | else { return defined $pat ? [split $pat, $str ] : [split ' ', $str ] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 27 | ▶ | sub vmethod_substr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vmethod_substr: called CC=5 SCAR=18.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 27 | my ($str, $i, $len, $replace) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 27 | ▶ | $i ||= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$i ||= 0
MC/DC0%0/1
$i ||= 0
$i
Truth table50%1/2
A
A= $i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 27 | ▶ | return '' if ! defined $str; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 27 | ▶ | return substr($str, $i) if ! defined $len; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 27 | ▶ | return substr($str, $i, $len) if ! defined $replace; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | substr($str, $i, $len, $replace); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 6 | ▶ | sub vmethod_uri { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vmethod_uri: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 6 | my $str = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 6 | ▶ | return '' if ! defined $str; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 6 | ▶ | utf8::upgrade($str) if defined &utf8::upgrade; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 6 | $str =~ s/([^A-Za-z0-9\-_.!~*\'()])/sprintf('%%%02X', ord($1))/eg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 6 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 2 | ▶ | sub vmethod_url { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vmethod_url: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 2 | my $str = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 2 | ▶ | return '' if ! defined $str; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 2 | ▶ | utf8::upgrade($str) if defined &utf8::upgrade; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 2 | $str =~ s/([^;\/?:@&=+\$,A-Za-z0-9\-_.!~*\'()])/sprintf('%%%02X', ord($1))/eg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 2 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | sub item_method_redirect { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
item_method_redirect: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | my ($t, $text, $file, $options) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | my $path = $t->{'OUTPUT_PATH'} || $t->throw('redirect', 'OUTPUT_PATH is not set'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$t->{'OUTPUT_PATH'} || $t->throw('redirect', 'OUTPUT_PATH is not set')
MC/DC0%0/2
$t->{'OUTPUT_PATH'} || $t->throw('redirect', 'OUTPUT_PATH is not set')
$t->{'OUTPUT_PATH'}
$t->throw('redirect', 'OUTPUT_PATH is not set')
Truth table0%0/3
A || B
A= $t->{'OUTPUT_PATH'}B= $t->throw('redirect', 'OUTPUT_PATH is not set')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | $t->throw('redirect', 'Invalid filename - cannot include "/../"') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | if $file =~ m{(^|/)\.\./}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | if (! -d $path) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | require File::Path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | File::Path::mkpath($path) || $t->throw('redirect', "Couldn't mkpath \"$path\": $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | ▶ | open (my $fh, '>', "$path/$file") || $t->throw('redirect', "Couldn't open \"$file\": $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | if (my $bm = (! $options) ? 0 : ref($options) ? $options->{'binmode'} : $options) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | if (+$bm == 1) { binmode $fh } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | else { binmode $fh, $bm} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | print $fh $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 10 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||