| 1 | package PICA::Path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 17 | ▶ | use v5.14.1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 17 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 17 | our $VERSION = '2.12'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 17 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 17 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 17 | our @EXPORT_OK = qw(pica_field_matcher); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 17 | ▶ | use Carp qw(confess); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 17 | ▶ | use Scalar::Util qw(reftype); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 17 | ▶ | use List::Util qw(any); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 17 | ▶ | use overload '""' => \&stringify; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 417 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 417 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 417 | ▶ | my $self = parse(@_) or confess "invalid pica path"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 406 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 17 | our $TAG = '(?<tag>[012.][0-9.][0-9.][A-Z@.])'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 17 | our $SUBFIELDS = '(?<subfields>[A-Za-z0-9]+|\*)'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 17 | our $POSITION = '(?<position>(\d+)?(-(\d+)?)?)'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 17 | our $OCCURRENCE = '(?<occurrence>(\d+-\d+|[0-9.]{1,3}|\*))'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 417 | ▶ | sub parse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=25 SCAR=32.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 417 | my ($path) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 417 | my $pattern = qr{^ | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | $TAG | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | (\[$OCCURRENCE\] | \/$OCCURRENCE)? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ([\$.]?$SUBFIELDS)? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | (\/$POSITION)? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | $}x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 417 | ▶ | return if $path !~ $pattern; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 408 | my $field = $+{tag}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 408 | my $occurrence = $+{occurrence}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 408 | my $subfield = $+{subfields}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 408 | my $position = $+{position}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 408 | ▶ | if ($subfield eq '*') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 16 | $subfield = qr{[A-Za-z0-9]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | elsif (defined $subfield) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 170 | $subfield = qr{[$subfield]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | elsif (defined $position) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 3 | $subfield = qr{[A-Za-z0-9]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 408 | ▶ | if ($occurrence eq '*' or (!$occurrence && $field =~ /^[2.]/)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition100%6/6
$occurrence eq "*" or not $occurrence and $field =~ /^[2.]/u
not $occurrence and $field =~ /^[2.]/u
MC/DC100%3/3
$occurrence eq "*" or not $occurrence and $field =~ /^[2.]/u
$occurrence eq "*"
not $occurrence
$field =~ /^[2.]/u
Truth table100%4/4
A or not(B) and C
A= $occurrence eq "*"B= not $occurrenceC= $field =~ /^[2.]/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 104 | $occurrence = '*'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | elsif ($occurrence =~ /^0*$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 289 | $occurrence = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | elsif ($occurrence =~ /-/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 9 | my ($from, $to) = map {1 * $_} split '-', $occurrence; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 9 | ▶ | if ($from eq $to) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 1 | $occurrence = qr{$from}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | elsif ($from < $to) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 7 | $occurrence = [$from, $to]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | elsif (defined $occurrence) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 6 | $occurrence = qr{$occurrence}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 407 | my @pos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 407 | ▶ | if (defined $position) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 17 | $position =~ $POSITION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 17 | my ($from, $dash, $to, $length) = ($2, $3, $4, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 17 | ▶ | if ($dash) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 14 | ▶ | return unless defined($from // $to); # /- | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$from // $to
MC/DC100%2/2
$from // $to
$from
$to
Truth table100%3/3
A // B
A= $fromB= $to
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 16 | ▶ | if (defined $to) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 7 | ▶ | if (!$from and $dash) { # /-X | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $from and $dash
MC/DC50%1/2
not $from and $dash
not $from
$dash
Truth table66%2/3
not(A) and B
A= not $fromB= $dash
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 4 | $from = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 7 | $length = $to - $from + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 9 | ▶ | if ($dash) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 6 | $length = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 3 | $length = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 16 | ▶ | if (!defined $length or $length >= 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $length or $length >= 1
MC/DC0%0/2
not defined $length or $length >= 1
not defined $length
$length >= 1
Truth table66%2/3
not(A) or B
A= not defined $lengthB= $length >= 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 16 | ▶ | unless (!$from and !defined $length) { # /0- | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$from or defined $length
MC/DC100%2/2
$from or defined $length
$from
defined $length
Truth table100%3/3
A or B
A= $fromB= defined $length
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 13 | @pos = ($from, $length); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 406 | field => qr{$field}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | occurrence => $occurrence, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | subfield => $subfield, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | position => \@pos | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 63 | ▶ | sub match { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
match: called CC=14 SCAR=26.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 63 | my ($self, $record, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 63 | my %default_args = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | force_array => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | join => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | nested_arrays => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | pluck => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | split => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | value => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 63 | %args = (%default_args, %args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 63 | ▶ | if ($args{nested_arrays}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 11 | $args{split} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | # check if path exists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 63 | ▶ | if ($args{value}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 3 | my $value = $self->record_subfields($record); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 3 | ▶ | return $value ? $args{value} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | # gather values from matched subfields | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 60 | my @matches; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 60 | for my $field (@{$self->record_fields($record)}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 131 | ▶ | next unless defined $field; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | my @matched_subfields | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | = $args{pluck} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 131 | ▶ | ? $self->match_subfields($field, pluck => 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | : $self->match_subfields($field); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 131 | ▶ | next unless grep {defined $_} @matched_subfields; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 113 | ▶ | if ($args{split}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 65 | ▶ | if ($args{nested_arrays}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 33 | push @matches, \@matched_subfields; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 32 | push @matches, @matched_subfields; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 48 | push @matches, join($args{join}, @matched_subfields); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 60 | ▶ | if (@matches) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # return matched fields as array reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 58 | ▶ | if ($args{split}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 26 | ▶ | return $args{force_array} ? [\@matches] : \@matches; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | # ... or string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | return $args{force_array} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | ? \@matches | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 32 | ▶ | : join($args{join}, @matches); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 17 | *match_record = *match; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 25417 | ▶ | sub match_field { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
match_field: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 25417 | my ($self, $field) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 25417 | ▶ | return if $field->[0] !~ $self->{field}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 469 | my $spec = $self->{occurrence}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 469 | ▶ | if ($spec ne '*') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 189 | my $occ = $field->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 189 | ▶ | if (!$spec) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 178 | ▶ | return if $occ > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | elsif (ref $spec eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 5 | ▶ | return if $occ < $spec->[0] or $occ > $spec->[1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$occ < $spec->[0] or $occ > $spec->[1]
MC/DC100%2/2
$occ < $spec->[0] or $occ > $spec->[1]
$occ < $spec->[0]
$occ > $spec->[1]
Truth table100%3/3
A or B
A= $occ < $spec->[0]B= $occ > $spec->[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 6 | ▶ | return if $occ !~ $spec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 462 | return $field; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 2098 | ▶ | sub match_subfields { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
match_subfields: called CC=13 SCAR=25.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 2098 | my ($self, $field, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 2098 | my $subfield_regex = $self->{subfield}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 2098 | my $from = $self->{position}->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 2098 | my $length = $self->{position}->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 2098 | my @values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 2098 | ▶ | if ($args{pluck}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | # Treat the subfields as a hash index | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 7 | my $subfield_href = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 7 | ▶ | for (my $i = 2; $i < @{$field}; $i += 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 14 | push @{$subfield_href->{$field->[$i]}}, $field->[$i + 1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 7 | my $subfields = $self->{subfield}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 7 | $subfields =~ s{.*\[(.+)\].*}{$1}g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 7 | for my $subfield (split('', $subfields)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 14 | ▶ | my $value = $subfield_href->{$subfield} // [undef]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$subfield_href->{$subfield} // [undef]
MC/DC100%1/1
$subfield_href->{$subfield} // [undef]
$subfield_href->{$subfield}
Truth table100%2/2
A
A= $subfield_href->{$subfield}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 14 | ▶ | if (defined $from) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | push @values, map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 2 | ▶ | $length | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | ? substr($_, $from, $length) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | : substr($_, $from) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 2 | } @{$value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 12 | push @values, @{$value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 2091 | ▶ | for (my $i = 2; $i < @$field; $i += 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 3257 | ▶ | if ($field->[$i] =~ $subfield_regex) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 2138 | my $value = $field->[$i + 1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 2138 | ▶ | if (defined $from) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 9 | ▶ | $value | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | = $length | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | ? substr($value, $from, $length) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | : substr($value, $from); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 9 | ▶ | next if '' eq ($value // ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$value // ""
MC/DC0%0/1
$value // ""
$value
Truth table50%1/2
A
A= $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 2137 | push @values, $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 2098 | return @values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 60 | ▶ | sub record_fields { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
record_fields: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 60 | my ($self, $record) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 60 | ▶ | $record = $record->{record} if reftype $record eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 60 | return [grep {$self->match_field($_)} @$record]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 13 | ▶ | sub record_subfields { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
record_subfields: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 13 | my ($self, $record) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 13 | ▶ | $record = $record->{record} if reftype $record eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 13 | my @values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 13 | foreach my $field (grep {$self->match_field($_)} @$record) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 20 | push @values, $self->match_subfields($field); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 13 | return @values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 135 | ▶ | sub unescape { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unescape: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 135 | my $exp = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 135 | ▶ | $exp =~ s/^\(\?[^:]*:(.*)\)$/$1/ if defined $exp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 135 | return $exp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 50 | ▶ | sub stringify { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stringify: called CC=10 SCAR=23.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 50 | my ($self, $short) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 50 | my $str = $self->fields; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 50 | my $occurrence = $self->occurrences; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 50 | ▶ | if (defined $occurrence) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 22 | ▶ | $str .= "/$occurrence" unless $str =~ /^[2.]/ and $occurrence eq '*'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$str =~ /^[2.]/u and $occurrence eq "*"
MC/DC50%1/2
$str =~ /^[2.]/u and $occurrence eq "*"
$str =~ /^[2.]/u
$occurrence eq "*"
Truth table66%2/3
A and B
A= $str =~ /^[2.]/uB= $occurrence eq "*"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 50 | my $subfields = $self->subfields; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 50 | ▶ | if (defined $subfields) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 27 | ▶ | unless ($short and $subfields !~ /^\$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$short and not $subfields =~ /^\$/u
MC/DC50%1/2
$short and not $subfields =~ /^\$/u
$short
not $subfields =~ /^\$/u
Truth table66%2/3
A and not(B)
A= $shortB= not $subfields =~ /^\$/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 26 | $str .= '$'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 27 | $str .= $subfields; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 50 | my $pos = $self->positions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 50 | ▶ | if (defined $pos) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 6 | ▶ | $str | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $subfields or defined $occurrence
MC/DC0%0/2
defined $subfields or defined $occurrence
defined $subfields
defined $occurrence
Truth table33%1/3
A or B
A= defined $subfieldsB= defined $occurrence
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | .= (defined $subfields || defined $occurrence) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | ? "/$pos" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | : "\$*/$pos"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 50 | $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 52 | ▶ | sub fields { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fields: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 52 | return unescape($_[0]->{field}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 52 | ▶ | sub occurrences { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
occurrences: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 52 | my $occ = $_[0]->{occurrence}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 52 | ▶ | return join "-", @$occ if ref $occ eq 'ARRAY'; # range | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 48 | return unescape($occ); # pattern | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 59 | ▶ | sub subfields { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subfields: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 59 | ▶ | return unless defined $_[0]->{subfield}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 35 | my $subfields = unescape($_[0]->{subfield}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 35 | ▶ | if ($subfields eq '[A-Za-z0-9]') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 16 | return '*'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 19 | $subfields =~ s/\[|\]//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 19 | return $subfields; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 52 | ▶ | sub positions { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
positions: called CC=8 SCAR=21.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 52 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 52 | my ($from, $length, $pos) = @{$self->{position}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 52 | ▶ | if (defined $from) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 7 | ▶ | if ($from) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 7 | $pos = $from; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 7 | ▶ | if (!defined $length) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 2 | ▶ | if ($from) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 2 | $pos = "$from-"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | elsif ($length > 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 3 | $pos .= '-' . ($from + $length - 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | ▶ | elsif ($length == 1 && !$from) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$length == 1 and not $from
MC/DC0%0/2
$length == 1 and not $from
$length == 1
not $from
Truth table33%1/3
A and not(B)
A= $length == 1B= not $from
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | $pos = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 52 | return $pos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 158 | ▶ | sub pica_field_matcher { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pica_field_matcher: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 158 | ▶ | my @pathes = map {ref $_ ? $_ : PICA::Path->new($_)} @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 24452 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 24452 | my $field = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 24452 | ▶ | any {$_->match_field($field)} @pathes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 157 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 17 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||