lib/MARC/Transform.pm

filter: Statementstmt 90.0% 1242 / 1380 Branchbran 62.3% 237 / 380 Conditioncond 49.1% 84 / 171 MC/DCmcdc 27.7% 28 / 101 Subroutinesub 98.9% 287 / 290 Podpod 20.5% 7 / 34 totaltotal 80.0% 1885 / 2356 CC 278 SCAR 57.1
CC
278
Cov
81%
parsesubaction
856.6
transform
822.3
new
31.8
CRAP 300.7
↑ Summary
1 # vim: sw=4
2 package MARC::Transform;
3 1 ▶use 5.10.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use MARC::Record;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use YAML;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Scalar::Util qw< reftype >;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 our $VERSION = '0.003009';
11 1 our $DEBUG = 0;
12 0 ▶sub debug { $DEBUG and say STDERR @_ }
Subroutine debug: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$MARC::Transform::DEBUG and say STDERR @_ 0 0 0
13  
14 1 my %fields;
15 my $globalcondition;
16 1 my $record;
17 1 our $mth;
18 1 my $globalsubs;
19 1 my $verbose=0;
20 1 my @errors;
21 my $global_LUT;
22 1 our $this="";
23  
24 29 ▶sub new {
Subroutine new: called CC=24 SCAR=34.6
Pod documented
25 29 my ($self,$recordsource,$yaml,$mthsource,$verb,$yamlencode) = @_;
26 29 my @yaml;
27 1 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
28 1 ▶ no warnings 'newline';
Subroutine BEGIN: called CC=1 SCAR=0.0
29 my $yamltoload;
30 29 ▶ if ( -e $yaml ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $yaml) { } 0 29 29
31 0 my $yamls;
32 0 ▶ if(defnonull($yamlencode)){
Branch: 1 branch
BranchTrueFalseTotal
if (defnonull($yamlencode)) { } 0 0 0
33 0 ▶ open $yamls, "<:encoding($yamlencode)", $yaml or die "can't open file: $!";
Branch: 1 branch
BranchTrueFalseTotal
open $yamls, "<:encoding($yamlencode)", $yaml or die "can't open file: $!" 0 0 0
34 } else {
35 0 ▶ open $yamls, "< $yaml" or die "can't open file: $!";
Branch: 1 branch
BranchTrueFalseTotal
open $yamls, "< $yaml" or die "can't open file: $!" 0 0 0
36 }
37 0 my $yamlline;
38 0 ▶ while ($yamlline = <$yamls>){ $yamltoload.=$yamlline; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined($yamlline = readline $yamls)) 0 0 0
39 0 close $yamls;
40 #@yaml = YAML::LoadFile($yamls);
41 }
42 else {
43 29 $yamltoload=$yaml;
44 #@yaml = YAML::Load($yaml);
45 }
46 29 $yamltoload=~s/#_dollars_#/\\#_dollars_\\#/g;
47 29 $yamltoload=~s/#_dbquote_#/\\#_dbquote_\\#/g;
48 29 @yaml = YAML::Load($yamltoload);
49 #warn "================". Data::Dumper::Dumper (\@yaml)."------------------";
50 29 $record=$recordsource;
51 29 $mth=$mthsource;
52 29 ▶ $$mth{"_defaultLUT_to_mth_"}={} if $mth;
Branch: 1 branch
BranchTrueFalseTotal
if $MARC::Transform::mth 6 23 29
53 29 ReplaceAllInRecord("before");
54 29 ▶ $verbose = 1 if ($verb);
Branch: 1 branch
BranchTrueFalseTotal
if $verb 0 29 29
55 29 foreach my $rulesub(@yaml) {
56 79 ▶ if ( ref($rulesub) eq "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $rulesub eq "HASH") 67 12 79
57 67 ▶ if ( defnonull ( $$rulesub{'global_subs'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defnonull($rulesub->{"global_subs"})) 6 61 67
58 6 $globalsubs = $$rulesub{'global_subs'};
59 0 ▶ eval ($globalsubs);
Subroutine areturn_record_encoding: called CC=1 SCAR=0.0
Subroutine atrim: called CC=1 SCAR=0.0
Subroutine reencodeRecordtoUtf8: called CC=1 SCAR=0.0
Subroutine reencodeRecordtoUtf8: called CC=1 SCAR=0.0
Subroutine test20b: called CC=1 SCAR=0.0
Subroutine test24b: called CC=1 SCAR=0.0
Subroutine test24b: called CC=1 SCAR=0.0
Subroutine warnfee: not called CC=1 SCAR=0.0
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
60 }
61 67 ▶ if ( defnonull ( $$rulesub{'global_LUT'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defnonull($rulesub->{"global_LUT"})) 3 64 67
62 3 ▶ if (ref($$rulesub{'global_LUT'}) eq "HASH") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $rulesub->{"global_LUT"} eq "HASH") 3 0 3
63 3 $global_LUT=$$rulesub{'global_LUT'};
64 }
65 }
66 }
67 }
68 29 foreach my $rule(@yaml) {
69 #print Data::Dumper::Dumper ($rule);
70 79 ▶ if ( ref($rule) eq "ARRAY" ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $rule eq 'ARRAY') { } 12 67 79
elsif (ref $rule eq 'HASH') { } 67 0 67
71 12 my $subs="";
72 12 foreach my $rul ( @$rule ) {
73 28 ▶ if ( defnonull ( $$rul{'subs'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defnonull($rul->{"subs"})) 7 21 28
74 7 $subs.=$$rul{'subs'};
75 }
76 28 ▶ if ( defnonull ( $$rul{'LUT'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defnonull($rul->{"LUT"})) 3 25 28
77 3 $$global_LUT{"lookuptableforthis"}=$$rul{'LUT'};#warn Data::Dumper::Dumper $global_LUT;
78 }
79 }
80 12 foreach my $rul ( @$rule ) {
81 13 my ($actionsin, $actionsinter, $actionsout)= parseactions($rul);#warn Data::Dumper::Dumper ($rul);
82 13 my $boolcondition = testrule($rul, $actionsin, $actionsinter, $actionsout, $subs);
83 #warn $boolcondition;warn "actionsin : ".$actionsin;warn "actionsout : ".$actionsout;
84 13 ▶ if ($boolcondition) {
Branch: 1 branch
BranchTrueFalseTotal
if ($boolcondition) 12 1 13
85 12 last;
86 }
87 }
88 }
89 elsif ( ref($rule) eq "HASH" ) {
90 67 my $subs="";
91 67 ▶ if ( defnonull ( $$rule{'subs'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defnonull($rule->{"subs"})) 0 67 67
92 0 $subs.=$$rule{'subs'};
93 }
94 67 ▶ if ( defnonull ( $$rule{'LUT'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defnonull($rule->{"LUT"})) 1 66 67
95 1 $$global_LUT{"lookuptableforthis"}=$$rule{'LUT'};
96 }
97 67 my ($actionsin, $actionsinter, $actionsout)= parseactions($rule);
98 67 my $boolcondition = testrule($rule, $actionsin, $actionsinter, $actionsout, $subs);
99 }
100 else {
101 0 push(@errors, 'Invalid yaml : you try to use a scalar rule.'); #error
102 }
103 }
104 29 foreach my $error (@errors) {
105 0 print "\n$error";
106 }
107 29 ReplaceAllInRecord("after");
108 29 $record;
109 }
110  
111 1046 ▶sub defnonull { my $var = shift; if (defined $var and $var ne "") { return 1; } else { return 0; } }
Subroutine defnonull: called CC=3 SCAR=11.0
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if (defined $var and $var ne '') { } 165 881 1046
Condition66%2/3
defined $var and $var ne ""
!ll&&!rl&&r
8810165
MC/DC50%1/2
defined $var and $var ne ""
defined $var $var ne ""
Truth table66%2/3
A and B
A= defined $varB= $var ne ""
ABresult
0X0
100
111
112  
113 11 ▶sub LUT {
Subroutine LUT: called CC=10 SCAR=23.2
Pod documented
114 11 my ( $inLUT, $type ) = @_;
115 11 ▶ if (!defined($type)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $type) 5 6 11
116 5 $type = "lookuptableforthis";
117 }
118 11 my $outLUT=$inLUT;
119 11 my $boolnocor = 1;
120 11 ▶ if ( ref($global_LUT) eq "HASH") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $global_LUT eq "HASH") 11 0 11
121 11 ▶ if (exists($$global_LUT{$type})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $global_LUT->{$type}) 11 0 11
122 11 my $correspondance=$$global_LUT{$type};
123 11 ▶ if ( ref($correspondance) eq "HASH") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $correspondance eq "HASH") 11 0 11
124 11 foreach my $cor (keys(%$correspondance)) {
125 30 ▶ if ($inLUT eq $cor) {
Branch: 1 branch
BranchTrueFalseTotal
if ($inLUT eq $cor) 9 21 30
126 9 $outLUT=$$correspondance{$cor};
127 9 $boolnocor = 0;
128 }
129 }
130 11 ▶ if ($boolnocor) {
Branch: 1 branch
BranchTrueFalseTotal
if ($boolnocor) 2 9 11
131 2 ▶ $outLUT=$$correspondance{"_default_value_"} if (defnonull($$correspondance{"_default_value_"}));
Branch: 1 branch
BranchTrueFalseTotal
if defnonull($correspondance->{"_default_value_"}) 1 1 2
132 2 ▶ push (@{$$mth{"_defaultLUT_to_mth_"}->{"$type"}} , $inLUT) if $mth;
Branch: 1 branch
BranchTrueFalseTotal
if $MARC::Transform::mth 2 0 2
133 }
134 }
135 }
136 }
137 11 return $outLUT;
138 }
139  
140 24 ▶sub update {
Subroutine update: called CC=1 SCAR=0.0
Pod documented
141 24 my ($field,$subfields)=@_;
142 24 transform ("update",$field,$subfields);
143 24 return 1;
144 }
145 29 ▶sub forceupdate {
Subroutine forceupdate: called CC=1 SCAR=0.0
Pod documented
146 29 my ($field,$subfields)=@_;
147 29 transform ("forceupdate",$field,$subfields);
148 29 return 1;
149 }
150 5 ▶sub updatefirst {
Subroutine updatefirst: called CC=1 SCAR=0.0
Pod documented
151 5 my ($field,$subfields)=@_;
152 5 transform ("updatefirst",$field,$subfields);
153 5 return 1;
154 }
155 5 ▶sub forceupdatefirst {
Subroutine forceupdatefirst: called CC=1 SCAR=0.0
Pod documented
156 5 my ($field,$subfields)=@_;
157 5 transform ("forceupdatefirst",$field,$subfields);
158 5 return 1;
159 }
160 24 ▶sub create {
Subroutine create: called CC=1 SCAR=0.0
Pod documented
161 24 my ($field,$subfields)=@_;
162 24 transform ("create",$field,$subfields);
163 24 return 1;
164 }
165  
166 87 ▶sub transform {
Subroutine transform: called CC=102 SCAR=67.1
Pod undocumented
167 87 my ($ttype,$field,$subfields)=@_;
168 #print "\n------------$ttype------------ : \n".Data::Dumper::Dumper (@_);
169 87 ▶ if ($ttype eq "forceupdate" or $ttype eq "forceupdatefirst" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ttype eq "forceupdate" or $ttype eq "forceupdatefirst") 34 53 87
Condition100%3/3
$ttype eq "forceupdate" or $ttype eq "forceupdatefirst"
l!l&&r!l&&!r
29553
MC/DC100%2/2
$ttype eq "forceupdate" or $ttype eq "forceupdatefirst"
$ttype eq "forceupdate" $ttype eq "forceupdatefirst"
Truth table100%3/3
A or B
A= $ttype eq "forceupdate"B= $ttype eq "forceupdatefirst"
ABresult
1X1
011
000
170 34 ▶ if (ref($field) eq "" or ref($field) eq "SCALAR") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $field eq "" or ref $field eq "SCALAR") 28 6 34
Condition66%2/3
ref $field eq "" or ref $field eq "SCALAR"
l!l&&r!l&&!r
2806
MC/DC50%1/2
ref $field eq "" or ref $field eq "SCALAR"
ref $field eq "" ref $field eq "SCALAR"
Truth table66%2/3
A or B
A= ref $field eq ""B= ref $field eq "SCALAR"
ABresult
1X1
011
000
171 28 ▶ if (!defined $record->field($field) ) {$ttype="create"}
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $record->field($field)) 10 18 28
172 }
173 }
174 87 ▶ if (ref($field) eq "MARC::Field") {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $field eq 'MARC::Field') { } 27 60 87
elsif (ref $field eq '' or ref $field eq 'SCALAR') { } 60 0 60
175 #print "\n------------$ttype------------ : \n".Data::Dumper::Dumper ($subfields);
176 27 foreach my $tag(keys(%$subfields)) {
177 27 ▶ if ( $tag eq 'i1' or $tag eq 'µ') {
Branch: 2 branches
BranchTrueFalseTotal
if ($tag eq 'i1' or $tag eq "\302\265") { } 0 27 27
elsif ($tag eq 'i2' or $tag eq "\302\243") { } 0 27 27
Condition33%1/3
$tag eq "i1" or $tag eq "\302\265"
l!l&&r!l&&!r
0027
MC/DC0%0/2
$tag eq "i1" or $tag eq "\302\265"
$tag eq "i1" $tag eq "\302\265"
Truth table33%1/3
A or B
A= $tag eq "i1"B= $tag eq "\302\265"
ABresult
1X1
011
000
178 #print "\n------------$ttype------------ : \n";
179 0 $this=$field->indicator(1);
180 0 my $finalvalue=parsestringactions($$subfields{$tag});
181 0 ▶ $field->update( ind1 => $finalvalue ) if ( ref($$subfields{$tag}) eq "" or ref($$subfields{$tag}) eq "SCALAR" );
Branch: 1 branch
BranchTrueFalseTotal
if ref $subfields->{$tag} eq "" or ref $subfields->{$tag} eq "SCALAR" 0 0 0
Condition0%0/3
ref $subfields->{$tag} eq "" or ref $subfields->{$tag} eq "SCALAR"
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $subfields->{$tag} eq "" or ref $subfields->{$tag} eq "SCALAR"
ref $subfields->{$tag} eq "" ref $subfields->{$tag} eq "SCALAR"
Truth table0%0/3
A or B
A= ref $subfields->{$tag} eq ""B= ref $subfields->{$tag} eq "SCALAR"
ABresult
1X1
011
000
182 }
183 ▶ elsif ( $tag eq 'i2' or $tag eq '£') {
Condition33%1/3
$tag eq "i2" or $tag eq "\302\243"
l!l&&r!l&&!r
0027
MC/DC0%0/2
$tag eq "i2" or $tag eq "\302\243"
$tag eq "i2" $tag eq "\302\243"
Truth table33%1/3
A or B
A= $tag eq "i2"B= $tag eq "\302\243"
ABresult
1X1
011
000
184 0 $this=$field->indicator(2);
185 0 my $finalvalue=parsestringactions($$subfields{$tag});
186 0 ▶ $field->update( ind2 => $finalvalue ) if ( ref($$subfields{$tag}) eq "" or ref($$subfields{$tag}) eq "SCALAR" );
Branch: 1 branch
BranchTrueFalseTotal
if ref $subfields->{$tag} eq "" or ref $subfields->{$tag} eq "SCALAR" 0 0 0
Condition0%0/3
ref $subfields->{$tag} eq "" or ref $subfields->{$tag} eq "SCALAR"
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $subfields->{$tag} eq "" or ref $subfields->{$tag} eq "SCALAR"
ref $subfields->{$tag} eq "" ref $subfields->{$tag} eq "SCALAR"
Truth table0%0/3
A or B
A= ref $subfields->{$tag} eq ""B= ref $subfields->{$tag} eq "SCALAR"
ABresult
1X1
011
000
187 }
188 else {
189 27 ▶ if( ref($$subfields{$tag}) eq "" or ref($$subfields{$tag}) eq "SCALAR" ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $subfields->{$tag} eq '' or ref $subfields->{$tag} eq 'SCALAR') { } 27 0 27
elsif (ref $subfields->{$tag} eq 'ARRAY') { } 0 0 0
Condition33%1/3
ref $subfields->{$tag} eq "" or ref $subfields->{$tag} eq "SCALAR"
l!l&&r!l&&!r
2700
MC/DC0%0/2
ref $subfields->{$tag} eq "" or ref $subfields->{$tag} eq "SCALAR"
ref $subfields->{$tag} eq "" ref $subfields->{$tag} eq "SCALAR"
Truth table33%1/3
A or B
A= ref $subfields->{$tag} eq ""B= ref $subfields->{$tag} eq "SCALAR"
ABresult
1X1
011
000
190 27 ▶ if($field->is_control_field()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($field->is_control_field) { } 0 27 27
191 0 $this=$field->data();
192 0 my $finalvalue=parsestringactions($$subfields{$tag});
193 0 $field->update($finalvalue);
194 }
195 else {
196 27 ▶ if ($ttype eq "create") {
Branch: 3 branches
BranchTrueFalseTotal
if ($ttype eq 'create') { } 6 21 27
elsif ($ttype eq 'updatefirst') { } 1 20 21
elsif ($ttype eq 'forceupdatefirst') { } 3 17 20
197 6 $this="";
198 6 my $finalvalue=parsestringactions($$subfields{$tag});
199 6 $field->add_subfields( $tag => $finalvalue );
200 }
201 elsif ($ttype eq "updatefirst") {
202 1 ▶ if ( defined $field->subfield( $tag ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $field->subfield($tag)) 1 0 1
203 1 $this=$field->subfield( $tag );
204 1 my $finalvalue=parsestringactions($$subfields{$tag});
205 1 $field->update( $tag => $finalvalue );
206 }
207 #warn $tag.$$subfields{$tag};
208 }
209 elsif ($ttype eq "forceupdatefirst") {
210 3 ▶ if ( defined $field->subfield( $tag ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $field->subfield($tag)) { } 3 0 3
211 3 $this=$field->subfield( $tag );
212 3 my $finalvalue=parsestringactions($$subfields{$tag});
213 3 $field->update( $tag => $finalvalue );
214 }
215 else {
216 0 $this="";
217 0 my $finalvalue=parsestringactions($$subfields{$tag});
218 0 $field->add_subfields( $tag => $finalvalue );
219 }
220 }
221 }
222 }
223 elsif( ref($$subfields{$tag}) eq "ARRAY" ) {
224 0 ▶ if(!$field->is_control_field()) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $field->is_control_field) { } 0 0 0
225 0 foreach my $subfield(@{$$subfields{$tag}}) {
226 0 ▶ if ($ttype eq "create") {
Branch: 3 branches
BranchTrueFalseTotal
if ($ttype eq 'create') { } 0 0 0
elsif ($ttype eq 'updatefirst') { } 0 0 0
elsif ($ttype eq 'forceupdatefirst') { } 0 0 0
227 0 $this="";
228 0 my $finalvalue=parsestringactions($subfield);
229 0 $field->add_subfields( $tag => $finalvalue );
230 }
231 elsif ($ttype eq "updatefirst") {
232 0 ▶ if ( defined $field->subfield( $tag ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $field->subfield($tag)) 0 0 0
233 0 $this=$field->subfield( $tag );
234 0 my $finalvalue=parsestringactions($subfield);
235 0 $field->update( $tag => $finalvalue );
236 }
237 }
238 elsif ($ttype eq "forceupdatefirst") {
239 0 ▶ if ( defined $field->subfield( $tag ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $field->subfield($tag)) { } 0 0 0
240 0 $this=$field->subfield( $tag );
241 0 my $finalvalue=parsestringactions($subfield);
242 0 $field->update( $tag => $finalvalue );
243 }
244 else {
245 0 $this="";
246 0 my $finalvalue=parsestringactions($subfield);
247 0 $field->add_subfields( $tag => $finalvalue );
248 }
249 }
250 }
251 }
252 else {
253 0 push(@errors, 'Invalid yaml : you try to use an array to '.$ttype.' in existing condition\'s controlfield value.'); #error
254 }
255 }
256 }
257 }
258 27 ▶ if((!$field->is_control_field()) and ($ttype eq "update" or $ttype eq "forceupdate" )) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $field->is_control_field and $ttype eq "update" || $ttype eq "forceupdate") 17 10 27
Condition83%5/6
not $field->is_control_field and $ttype eq "update" || $ttype eq "forceupdate"
!ll&&!rl&&r
01017
$ttype eq "update" or $ttype eq "forceupdate"
l!l&&r!l&&!r
14310
MC/DC66%2/3
not $field->is_control_field and $ttype eq "update" || $ttype eq "forceupdate"
not $field->is_control_field $ttype eq "update" $ttype eq "forceupdate"
Truth table75%3/4
not(A) and B or C
A= not $field->is_control_fieldB= $ttype eq "update"C= $ttype eq "forceupdate"
ABCresult
0XX0
1000
11X1
1011
259 17 my @usubfields;
260 17 foreach my $subfield ( $field->subfields() ) {
261 58 ▶ if ( exists($$subfields{$$subfield[0]}) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$subfields{$subfield->[0]}) { } 15 43 58
262 #implementation de l'eval des fonctions et de $this
263 15 $this=$$subfield[1];
264 15 my $finalvalue=parsestringactions($$subfields{$$subfield[0]});
265 15 push @usubfields, ( $$subfield[0],$finalvalue );
266 }
267 else {
268 43 push @usubfields, ( $$subfield[0], $$subfield[1] );
269 }
270 }
271 17 my $newfield = MARC::Field->new( $field->tag(), $field->indicator(1), $field->indicator(2), @usubfields );
272 17 foreach my $tag(keys(%$subfields)) {
273 17 ▶ if($tag ne 'i1' and $tag ne 'µ' and $tag ne 'i2' and $tag ne '£' and !defined($newfield->subfield( $tag )) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag ne "i1" and $tag ne "\302\265" and $tag ne "i2" and $tag ne "\302\243" and not defined $newfield->subfield($tag)) 2 15 17
Condition41%5/12
$tag ne "i1" and $tag ne "\302\265" and $tag ne "i2" and $tag ne "\302\243" and not defined $newfield->subfield($tag)
!ll&&!rl&&r
0152
$tag ne "i1" and $tag ne "\302\265" and $tag ne "i2" and $tag ne "\302\243"
!ll&&!rl&&r
0017
$tag ne "i1" and $tag ne "\302\265" and $tag ne "i2"
!ll&&!rl&&r
0017
$tag ne "i1" and $tag ne "\302\265"
!ll&&!rl&&r
0017
MC/DC20%1/5
$tag ne "i1" and $tag ne "\302\265" and $tag ne "i2" and $tag ne "\302\243" and not defined $newfield->subfield($tag)
$tag ne "i1" $tag ne "\302\265" $tag ne "i2" $tag ne "\302\243" not defined $newfield->subfield($tag)
Truth table33%2/6
A and B and C and D and not(E)
A= $tag ne "i1"B= $tag ne "\302\265"C= $tag ne "i2"D= $tag ne "\302\243"E= not defined $newfield->subfield($tag)
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
274 2 ▶ if( ref($$subfields{$tag}) eq "" or ref($$subfields{$tag}) eq "SCALAR" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $subfields->{$tag} eq '' or ref $subfields->{$tag} eq 'SCALAR') { } 2 0 2
Condition33%1/3
ref $subfields->{$tag} eq "" or ref $subfields->{$tag} eq "SCALAR"
l!l&&r!l&&!r
200
MC/DC0%0/2
ref $subfields->{$tag} eq "" or ref $subfields->{$tag} eq "SCALAR"
ref $subfields->{$tag} eq "" ref $subfields->{$tag} eq "SCALAR"
Truth table33%1/3
A or B
A= ref $subfields->{$tag} eq ""B= ref $subfields->{$tag} eq "SCALAR"
ABresult
1X1
011
000
275 2 $this="";
276 2 my $finalvalue=parsestringactions($$subfields{$tag});
277 2 ▶ $newfield->add_subfields( $tag => $finalvalue ) if $ttype eq "forceupdate";
Branch: 1 branch
BranchTrueFalseTotal
if $ttype eq "forceupdate" 2 0 2
278 }
279 else {
280 0 push(@errors, 'Invalid yaml : you try to use a non-scalar value to '.$ttype.' in existing condition\'s field value.'); #error
281 }
282 }
283 }
284 17 $field->replace_with($newfield);
285 }
286 }
287 ▶ elsif (ref($field) eq "" or ref($field) eq "SCALAR") {
Condition33%1/3
ref $field eq "" or ref $field eq "SCALAR"
l!l&&r!l&&!r
6000
MC/DC0%0/2
ref $field eq "" or ref $field eq "SCALAR"
ref $field eq "" ref $field eq "SCALAR"
Truth table33%1/3
A or B
A= ref $field eq ""B= ref $field eq "SCALAR"
ABresult
1X1
011
000
288 #print "\n------------$ttype------------ : \n".Data::Dumper::Dumper (@_);
289 60 ▶ if ($ttype eq "update" or $ttype eq "updatefirst" or $ttype eq "forceupdate" or $ttype eq "forceupdatefirst") {
Branch: 2 branches
BranchTrueFalseTotal
if ($ttype eq 'update' or $ttype eq 'updatefirst' or $ttype eq 'forceupdate' or $ttype eq 'forceupdatefirst') { } 32 28 60
elsif ($ttype eq 'create') { } 28 0 28
Condition100%9/9
$ttype eq "update" or $ttype eq "updatefirst" or $ttype eq "forceupdate" or $ttype eq "forceupdatefirst"
l!l&&r!l&&!r
31128
$ttype eq "update" or $ttype eq "updatefirst" or $ttype eq "forceupdate"
l!l&&r!l&&!r
141729
$ttype eq "update" or $ttype eq "updatefirst"
l!l&&r!l&&!r
10446
MC/DC100%4/4
$ttype eq "update" or $ttype eq "updatefirst" or $ttype eq "forceupdate" or $ttype eq "forceupdatefirst"
$ttype eq "update" $ttype eq "updatefirst" $ttype eq "forceupdate" $ttype eq "forceupdatefirst"
Truth table100%5/5
A or B or C or D
A= $ttype eq "update"B= $ttype eq "updatefirst"C= $ttype eq "forceupdate"D= $ttype eq "forceupdatefirst"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
290 32 ▶ if ( defined $record->field($field) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $record->field($field)) 32 0 32
291 32 for my $updatefield ( $record->field($field) ) {
292 42 foreach my $tag(keys(%$subfields)) {
293 46 ▶ if ( $tag eq 'i1' or $tag eq 'µ') {
Branch: 3 branches
BranchTrueFalseTotal
if ($tag eq 'i1' or $tag eq "\302\265") { } 0 46 46
elsif ($tag eq 'i2' or $tag eq "\302\243") { } 0 46 46
elsif (ref $subfields->{$tag} eq '' or ref $subfields->{$tag} eq 'SCALAR') { } 46 0 46
Condition33%1/3
$tag eq "i1" or $tag eq "\302\265"
l!l&&r!l&&!r
0046
MC/DC0%0/2
$tag eq "i1" or $tag eq "\302\265"
$tag eq "i1" $tag eq "\302\265"
Truth table33%1/3
A or B
A= $tag eq "i1"B= $tag eq "\302\265"
ABresult
1X1
011
000
294 0 $this=$updatefield->indicator(1);
295 0 my $finalvalue=parsestringactions($$subfields{$tag});
296 0 ▶ $updatefield->update( ind1 => $finalvalue ) if ( ref($$subfields{$tag}) eq "" or ref($$subfields{$tag}) eq "SCALAR" );
Branch: 1 branch
BranchTrueFalseTotal
if ref $subfields->{$tag} eq "" or ref $subfields->{$tag} eq "SCALAR" 0 0 0
Condition0%0/3
ref $subfields->{$tag} eq "" or ref $subfields->{$tag} eq "SCALAR"
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $subfields->{$tag} eq "" or ref $subfields->{$tag} eq "SCALAR"
ref $subfields->{$tag} eq "" ref $subfields->{$tag} eq "SCALAR"
Truth table0%0/3
A or B
A= ref $subfields->{$tag} eq ""B= ref $subfields->{$tag} eq "SCALAR"
ABresult
1X1
011
000
297 }
298 ▶ elsif ( $tag eq 'i2' or $tag eq '£') {
Condition33%1/3
$tag eq "i2" or $tag eq "\302\243"
l!l&&r!l&&!r
0046
MC/DC0%0/2
$tag eq "i2" or $tag eq "\302\243"
$tag eq "i2" $tag eq "\302\243"
Truth table33%1/3
A or B
A= $tag eq "i2"B= $tag eq "\302\243"
ABresult
1X1
011
000
299 0 $this=$updatefield->indicator(2);
300 0 my $finalvalue=parsestringactions($$subfields{$tag});
301 0 ▶ $updatefield->update( ind2 => $finalvalue ) if ( ref($$subfields{$tag}) eq "" or ref($$subfields{$tag}) eq "SCALAR" );
Branch: 1 branch
BranchTrueFalseTotal
if ref $subfields->{$tag} eq "" or ref $subfields->{$tag} eq "SCALAR" 0 0 0
Condition0%0/3
ref $subfields->{$tag} eq "" or ref $subfields->{$tag} eq "SCALAR"
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $subfields->{$tag} eq "" or ref $subfields->{$tag} eq "SCALAR"
ref $subfields->{$tag} eq "" ref $subfields->{$tag} eq "SCALAR"
Truth table0%0/3
A or B
A= ref $subfields->{$tag} eq ""B= ref $subfields->{$tag} eq "SCALAR"
ABresult
1X1
011
000
302 }
303 ▶ elsif( ref($$subfields{$tag}) eq "" or ref($$subfields{$tag}) eq "SCALAR" ) {
Condition33%1/3
ref $subfields->{$tag} eq "" or ref $subfields->{$tag} eq "SCALAR"
l!l&&r!l&&!r
4600
MC/DC0%0/2
ref $subfields->{$tag} eq "" or ref $subfields->{$tag} eq "SCALAR"
ref $subfields->{$tag} eq "" ref $subfields->{$tag} eq "SCALAR"
Truth table33%1/3
A or B
A= ref $subfields->{$tag} eq ""B= ref $subfields->{$tag} eq "SCALAR"
ABresult
1X1
011
000
304 46 ▶ if($updatefield->is_control_field()) {
Branch: 3 branches
BranchTrueFalseTotal
if ($updatefield->is_control_field) { } 2 44 46
elsif ($ttype eq 'updatefirst') { } 7 37 44
elsif ($ttype eq 'forceupdatefirst') { } 3 34 37
305 2 $this=$updatefield->data();
306 2 my $finalvalue=parsestringactions($$subfields{$tag});
307 2 $updatefield->update($finalvalue);
308 }
309 elsif ( $ttype eq "updatefirst" ) {
310 7 ▶ if ( defined $updatefield->subfield( $tag ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $updatefield->subfield($tag)) 6 1 7
311 6 $this=$updatefield->subfield( $tag );
312 6 my $finalvalue=parsestringactions($$subfields{$tag});
313 6 $updatefield->update( $tag => $finalvalue );
314 }
315 }
316 elsif ($ttype eq "forceupdatefirst") {
317 3 ▶ if ( defined $updatefield->subfield( $tag ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $updatefield->subfield($tag)) { } 2 1 3
318 2 $this=$updatefield->subfield( $tag );
319 2 my $finalvalue=parsestringactions($$subfields{$tag});
320 2 $updatefield->update( $tag => $finalvalue );
321 }
322 else {
323 1 $this="";
324 1 my $finalvalue=parsestringactions($$subfields{$tag});
325 1 $updatefield->add_subfields( $tag => $finalvalue );
326 }
327 }
328 }
329 else {
330 0 push(@errors, 'Invalid yaml : you try to use a non-scalar value to '.$ttype.' field.');#error
331 }
332 }
333 42 ▶ if((!$updatefield->is_control_field()) and ($ttype eq "update" or $ttype eq "forceupdate" )) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $updatefield->is_control_field and $ttype eq "update" || $ttype eq "forceupdate") 31 11 42
Condition100%6/6
not $updatefield->is_control_field and $ttype eq "update" || $ttype eq "forceupdate"
!ll&&!rl&&r
2931
$ttype eq "update" or $ttype eq "forceupdate"
l!l&&r!l&&!r
14179
MC/DC100%3/3
not $updatefield->is_control_field and $ttype eq "update" || $ttype eq "forceupdate"
not $updatefield->is_control_field $ttype eq "update" $ttype eq "forceupdate"
Truth table100%4/4
not(A) and B or C
A= not $updatefield->is_control_fieldB= $ttype eq "update"C= $ttype eq "forceupdate"
ABCresult
0XX0
1000
11X1
1011
334 31 my @usubfields;
335 31 foreach my $subfield ( $updatefield->subfields() ) {
336 121 ▶ if ( exists($$subfields{$$subfield[0]}) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$subfields{$subfield->[0]}) { } 26 95 121
337 26 $this=$$subfield[1];
338 26 my $finalvalue=parsestringactions($$subfields{$$subfield[0]});
339 26 push @usubfields, ( $$subfield[0],$finalvalue );
340 }
341 else {
342 95 push @usubfields, ( $$subfield[0], $$subfield[1] );
343 }
344 }
345 31 my $newfield = MARC::Field->new( $updatefield->tag(), $updatefield->indicator(1), $updatefield->indicator(2), @usubfields );
346 31 foreach my $tag(keys(%$subfields)) {
347 34 ▶ if($tag ne 'i1' and $tag ne 'µ' and $tag ne 'i2' and $tag ne '£' and !defined($newfield->subfield( $tag )) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag ne "i1" and $tag ne "\302\265" and $tag ne "i2" and $tag ne "\302\243" and not defined $newfield->subfield($tag)) 13 21 34
Condition41%5/12
$tag ne "i1" and $tag ne "\302\265" and $tag ne "i2" and $tag ne "\302\243" and not defined $newfield->subfield($tag)
!ll&&!rl&&r
02113
$tag ne "i1" and $tag ne "\302\265" and $tag ne "i2" and $tag ne "\302\243"
!ll&&!rl&&r
0034
$tag ne "i1" and $tag ne "\302\265" and $tag ne "i2"
!ll&&!rl&&r
0034
$tag ne "i1" and $tag ne "\302\265"
!ll&&!rl&&r
0034
MC/DC20%1/5
$tag ne "i1" and $tag ne "\302\265" and $tag ne "i2" and $tag ne "\302\243" and not defined $newfield->subfield($tag)
$tag ne "i1" $tag ne "\302\265" $tag ne "i2" $tag ne "\302\243" not defined $newfield->subfield($tag)
Truth table33%2/6
A and B and C and D and not(E)
A= $tag ne "i1"B= $tag ne "\302\265"C= $tag ne "i2"D= $tag ne "\302\243"E= not defined $newfield->subfield($tag)
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
348 13 ▶ if( ref($$subfields{$tag}) eq "" or ref($$subfields{$tag}) eq "SCALAR" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $subfields->{$tag} eq '' or ref $subfields->{$tag} eq 'SCALAR') { } 13 0 13
Condition33%1/3
ref $subfields->{$tag} eq "" or ref $subfields->{$tag} eq "SCALAR"
l!l&&r!l&&!r
1300
MC/DC0%0/2
ref $subfields->{$tag} eq "" or ref $subfields->{$tag} eq "SCALAR"
ref $subfields->{$tag} eq "" ref $subfields->{$tag} eq "SCALAR"
Truth table33%1/3
A or B
A= ref $subfields->{$tag} eq ""B= ref $subfields->{$tag} eq "SCALAR"
ABresult
1X1
011
000
349 13 $this="";
350 13 my $finalvalue=parsestringactions($$subfields{$tag});
351 13 ▶ $newfield->add_subfields( $tag => $finalvalue ) if $ttype eq "forceupdate";
Branch: 1 branch
BranchTrueFalseTotal
if $ttype eq "forceupdate" 12 1 13
352 }
353 else {
354 0 push(@errors, 'Invalid yaml : you try to use a non-scalar value to '.$ttype.' field.');#error
355 }
356 }
357 }
358 31 $updatefield->replace_with($newfield);
359 }
360 }
361 }
362 }
363 elsif ($ttype eq "create") {
364 28 my $newfield;
365 28 $this="";
366 28 ▶ if ($field < "010" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($field < 10) { } 2 26 28
367 2 $newfield = MARC::Field->new( $field, 'temp');
368 }
369 else {
370 26 $newfield = MARC::Field->new( $field, '', '', '0'=>'temp');
371 }
372
373 28 foreach my $tag(keys(%$subfields)) {
374 35 ▶ if ( $tag eq 'i1' or $tag eq 'µ') {
Branch: 2 branches
BranchTrueFalseTotal
if ($tag eq 'i1' or $tag eq "\302\265") { } 0 35 35
elsif ($tag eq 'i2' or $tag eq "\302\243") { } 0 35 35
Condition33%1/3
$tag eq "i1" or $tag eq "\302\265"
l!l&&r!l&&!r
0035
MC/DC0%0/2
$tag eq "i1" or $tag eq "\302\265"
$tag eq "i1" $tag eq "\302\265"
Truth table33%1/3
A or B
A= $tag eq "i1"B= $tag eq "\302\265"
ABresult
1X1
011
000
375 0 my $finalvalue=parsestringactions($$subfields{$tag});
376 0 ▶ $newfield->update( ind1 => $finalvalue ) if ( ref($$subfields{$tag}) eq "" or ref($$subfields{$tag}) eq "SCALAR" );
Branch: 1 branch
BranchTrueFalseTotal
if ref $subfields->{$tag} eq "" or ref $subfields->{$tag} eq "SCALAR" 0 0 0
Condition0%0/3
ref $subfields->{$tag} eq "" or ref $subfields->{$tag} eq "SCALAR"
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $subfields->{$tag} eq "" or ref $subfields->{$tag} eq "SCALAR"
ref $subfields->{$tag} eq "" ref $subfields->{$tag} eq "SCALAR"
Truth table0%0/3
A or B
A= ref $subfields->{$tag} eq ""B= ref $subfields->{$tag} eq "SCALAR"
ABresult
1X1
011
000
377 }
378 ▶ elsif ( $tag eq 'i2' or $tag eq '£') {
Condition33%1/3
$tag eq "i2" or $tag eq "\302\243"
l!l&&r!l&&!r
0035
MC/DC0%0/2
$tag eq "i2" or $tag eq "\302\243"
$tag eq "i2" $tag eq "\302\243"
Truth table33%1/3
A or B
A= $tag eq "i2"B= $tag eq "\302\243"
ABresult
1X1
011
000
379 0 my $finalvalue=parsestringactions($$subfields{$tag});
380 0 ▶ $newfield->update( ind2 => $finalvalue ) if ( ref($$subfields{$tag}) eq "" or ref($$subfields{$tag}) eq "SCALAR" );
Branch: 1 branch
BranchTrueFalseTotal
if ref $subfields->{$tag} eq "" or ref $subfields->{$tag} eq "SCALAR" 0 0 0
Condition0%0/3
ref $subfields->{$tag} eq "" or ref $subfields->{$tag} eq "SCALAR"
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $subfields->{$tag} eq "" or ref $subfields->{$tag} eq "SCALAR"
ref $subfields->{$tag} eq "" ref $subfields->{$tag} eq "SCALAR"
Truth table0%0/3
A or B
A= ref $subfields->{$tag} eq ""B= ref $subfields->{$tag} eq "SCALAR"
ABresult
1X1
011
000
381 }
382 else {
383 35 ▶ if( ref($$subfields{$tag}) eq "" or ref($$subfields{$tag}) eq "SCALAR" ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $subfields->{$tag} eq '' or ref $subfields->{$tag} eq 'SCALAR') { } 31 4 35
elsif (ref $subfields->{$tag} eq 'ARRAY') { } 4 0 4
Condition66%2/3
ref $subfields->{$tag} eq "" or ref $subfields->{$tag} eq "SCALAR"
l!l&&r!l&&!r
3104
MC/DC50%1/2
ref $subfields->{$tag} eq "" or ref $subfields->{$tag} eq "SCALAR"
ref $subfields->{$tag} eq "" ref $subfields->{$tag} eq "SCALAR"
Truth table66%2/3
A or B
A= ref $subfields->{$tag} eq ""B= ref $subfields->{$tag} eq "SCALAR"
ABresult
1X1
011
000
384 31 ▶ if($newfield->is_control_field()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($newfield->is_control_field) { } 2 29 31
385 2 my $finalvalue=parsestringactions($$subfields{$tag});
386 2 $newfield->update($finalvalue);
387 }
388 else {
389 29 my $finalvalue=parsestringactions($$subfields{$tag});
390 29 $newfield->add_subfields( $tag => $finalvalue );
391 }
392 }
393 elsif( ref($$subfields{$tag}) eq "ARRAY" ) {
394 4 ▶ if(!$newfield->is_control_field()) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($newfield->is_control_field) 4 0 4
395 4 foreach my $subfield(@{$$subfields{$tag}}) {
396 10 my $finalvalue=parsestringactions($subfield);
397 10 $newfield->add_subfields( $tag => $finalvalue );
398 }
399 }
400 }
401 }
402 }
403 28 ▶ if (!$newfield->is_control_field()) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($newfield->is_control_field) 26 2 28
404 26 $newfield->delete_subfield(pos => '0');
405 }
406 28 $record->insert_fields_ordered($newfield);
407 }
408 }
409 else {
410 0 push(@errors, 'Invalid yaml : you try to use an array or hash value to '.$ttype.' field.');#error
411 }
412 87 return 1;
413 }
414  
415 118 ▶sub parsestringactions {
Subroutine parsestringactions: called CC=2 SCAR=6.9
Pod undocumented
416 118 my $subfieldtemp=shift;
417 118 $subfieldtemp=~s/tempnameforcurrentvalueofthissubfield/\$this/g;
418 118 $subfieldtemp=~s/temporarycallfunction/\\&/g;
419 118 my $finalvalue;
420 118 ▶ if ($subfieldtemp=~/\\&/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subfieldtemp =~ /\\&/) { } 24 94 118
421 24 $subfieldtemp=~s/\\&/&/g;
422 24 $finalvalue = eval ($subfieldtemp);
423 }
424 else {
425 94 $finalvalue = eval '"'.$subfieldtemp.'"';
426 }
427 118 return $finalvalue;
428 }
429  
430 80 ▶sub parseactions {
Subroutine parseactions: called CC=9 SCAR=22.0
Pod undocumented
431 80 my $rul = shift;
432 80 my $actionsintemp="";
433 80 my $actionsin="";
434 80 my $actionsinter="";
435 80 my $actionsouttemp="";
436 80 my $actionsout="";
437 #print "\n".Data::Dumper::Dumper $rul;
438 #create duplicatefield forceupdate forceupdatefirst update updatefirst execute delete
439 80 ▶ if ( defnonull ( $$rul{'create'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defnonull($rul->{"create"})) 20 60 80
440 20 ($actionsintemp,$actionsouttemp)=parsesubaction ($$rul{'create'},'create');
441 20 $actionsin.=$actionsintemp; $actionsout.=$actionsouttemp;
442 }
443 80 ▶ if ( defnonull ( $$rul{'duplicatefield'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defnonull($rul->{"duplicatefield"})) 6 74 80
444 6 ($actionsintemp,$actionsouttemp)=parsesubaction ($$rul{'duplicatefield'},'duplicatefield');
445 6 $actionsinter.=$actionsintemp; $actionsout.=$actionsouttemp;
446 }
447 80 ▶ if ( defnonull ( $$rul{'forceupdate'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defnonull($rul->{"forceupdate"})) 22 58 80
448 22 ($actionsintemp,$actionsouttemp)=parsesubaction ($$rul{'forceupdate'},'forceupdate');
449 22 $actionsin.=$actionsintemp; $actionsout.=$actionsouttemp;
450 }
451 80 ▶ if ( defnonull ( $$rul{'forceupdatefirst'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defnonull($rul->{"forceupdatefirst"})) 3 77 80
452 3 ($actionsintemp,$actionsouttemp)=parsesubaction ($$rul{'forceupdatefirst'},'forceupdatefirst');
453 3 $actionsin.=$actionsintemp; $actionsout.=$actionsouttemp;
454 }
455 80 ▶ if ( defnonull ( $$rul{'update'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defnonull($rul->{"update"})) 11 69 80
456 11 ($actionsintemp,$actionsouttemp)=parsesubaction ($$rul{'update'},'update');
457 11 $actionsin.=$actionsintemp; $actionsout.=$actionsouttemp;
458 }
459 80 ▶ if ( defnonull ( $$rul{'updatefirst'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defnonull($rul->{"updatefirst"})) 3 77 80
460 3 ($actionsintemp,$actionsouttemp)=parsesubaction ($$rul{'updatefirst'},'updatefirst');
461 3 $actionsin.=$actionsintemp; $actionsout.=$actionsouttemp;
462 }
463 80 ▶ if ( defnonull ( $$rul{'execute'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defnonull($rul->{"execute"})) 7 73 80
464 7 ($actionsintemp,$actionsouttemp)=parsesubaction ($$rul{'execute'},'execute');
465 7 $actionsin.=$actionsintemp; $actionsout.=$actionsouttemp;
466 }
467 80 ▶ if ( defnonull ( $$rul{'delete'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defnonull($rul->{"delete"})) 12 68 80
468 12 ($actionsintemp,$actionsouttemp)=parsesubaction ($$rul{'delete'},'delete');
469 12 $actionsin.=$actionsintemp; $actionsout.=$actionsouttemp;
470 }
471 #print "\n----------------------actionsin---------------------- : \n$actionsin\n\n----------------------actionsout---------------------- : \n$actionsout\n----------------------actionsend----------------------";
472 80 return ($actionsin, $actionsinter, $actionsout)
473 }
474  
475 84 ▶sub parsesubaction {
Subroutine parsesubaction: called CC=99 SCAR=67.5
Pod undocumented
476 84 my ($intaction,$type)=@_;
477 84 my $actionsin="";
478 84 my $actionsout="";
479 84 my $boolin=0;
480 84 my $specaction="";
481 84 my $currentaction="";#warn ref($intaction);
482 84 $specaction=" $type";
483 #print "\n".Data::Dumper::Dumper $intaction;
484 84 ▶ if ($type eq "create" or $type eq "forceupdate" or $type eq "update" or $type eq "forceupdatefirst" or $type eq "updatefirst") {
Branch: 4 branches
BranchTrueFalseTotal
if ($type eq 'create' or $type eq 'forceupdate' or $type eq 'update' or $type eq 'forceupdatefirst' or $type eq 'updatefirst') { } 59 25 84
elsif ($type eq 'duplicatefield') { } 6 19 25
elsif ($type eq 'delete') { } 12 7 19
elsif ($type eq 'execute') { } 7 0 7
Condition100%12/12
$type eq "create" or $type eq "forceupdate" or $type eq "update" or $type eq "forceupdatefirst" or $type eq "updatefirst"
l!l&&r!l&&!r
56325
$type eq "create" or $type eq "forceupdate" or $type eq "update" or $type eq "forceupdatefirst"
l!l&&r!l&&!r
53328
$type eq "create" or $type eq "forceupdate" or $type eq "update"
l!l&&r!l&&!r
421131
$type eq "create" or $type eq "forceupdate"
l!l&&r!l&&!r
202242
MC/DC100%5/5
$type eq "create" or $type eq "forceupdate" or $type eq "update" or $type eq "forceupdatefirst" or $type eq "updatefirst"
$type eq "create" $type eq "forceupdate" $type eq "update" $type eq "forceupdatefirst" $type eq "updatefirst"
Truth table100%6/6
A or B or C or D or E
A= $type eq "create"B= $type eq "forceupdate"C= $type eq "update"D= $type eq "forceupdatefirst"E= $type eq "updatefirst"
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
485 59 ▶ if ( ref($intaction) eq "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $intaction eq 'HASH') { } 59 0 59
486 59 foreach my $kint (keys(%$intaction)) {
487 89 ▶ if( ref($$intaction{$kint}) eq "HASH" ) {
Branch: 3 branches
BranchTrueFalseTotal
if (ref $intaction->{$kint} eq 'HASH') { } 11 78 89
elsif (ref $intaction->{$kint} eq '' or ref $intaction->{$kint} eq 'SCALAR') { } 77 1 78
elsif (ref $intaction->{$kint} eq 'ARRAY') { } 1 0 1
488 11 my $ftag;
489 11 $currentaction="";
490 11 $boolin=0;
491 11 ▶ if($kint=~/^\$f(\d{3})$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($kint =~ /^\$f(\d{3})$/) { } 0 11 11
elsif ($kint =~ /^f(\d{3})$/) { } 11 0 11
492 0 $boolin=1;
493 0 $ftag=$kint;
494 }
495 elsif($kint=~/^f(\d{3})$/) {
496 11 $ftag='"'.$1.'"';
497 }
498 else {
499 0 push(@errors, 'Invalid yaml : your field reference is not valid in '.$type.' action.');#error
500 0 next;
501 }
502 11 $currentaction.=$specaction.'('.$ftag.',{';
503 11 my $subint=$$intaction{$kint};
504 11 foreach my $k (keys(%$subint)) {
505 22 ▶ if( ref($$subint{$k}) eq "" or ref($$subint{$k}) eq "SCALAR" ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $subint->{$k} eq '' or ref $subint->{$k} eq 'SCALAR') { } 19 3 22
elsif (ref $subint->{$k} eq 'ARRAY') { } 3 0 3
Condition66%2/3
ref $subint->{$k} eq "" or ref $subint->{$k} eq "SCALAR"
l!l&&r!l&&!r
1903
MC/DC50%1/2
ref $subint->{$k} eq "" or ref $subint->{$k} eq "SCALAR"
ref $subint->{$k} eq "" ref $subint->{$k} eq "SCALAR"
Truth table66%2/3
A or B
A= ref $subint->{$k} eq ""B= ref $subint->{$k} eq "SCALAR"
ABresult
1X1
011
000
506 19 $$subint{$k}=~s/"/\\"/g;
507 19 ▶ $boolin=1 if($$subint{$k}=~/\$f/);#print $k." eq. ".$$subint{$k}."\n";
Branch: 1 branch
BranchTrueFalseTotal
if $subint->{$k} =~ /\$f/ 6 13 19
508 19 $$subint{$k}=~s/\$this/tempnameforcurrentvalueofthissubfield/g;
509 19 $$subint{$k}=~s/\\&/temporarycallfunction/g;
510 19 $currentaction.='"'.$k.'"=> "'.$$subint{$k}.'",';
511 }
512 elsif( ref($$subint{$k}) eq "ARRAY" ) {
513 3 $currentaction.='"'.$k.'"=>[';
514 3 foreach my $ssubint(@{$$subint{$k}}) {
515 8 $ssubint=~s/"/\\"/g;
516 8 ▶ $boolin=1 if($ssubint=~/\$f/);
Branch: 1 branch
BranchTrueFalseTotal
if $ssubint =~ /\$f/ 0 8 8
517 8 $ssubint=~s/\$this/tempnameforcurrentvalueofthissubfield/g;
518 8 $ssubint=~s/\\&/temporarycallfunction/g;
519 8 $currentaction.='"'.$ssubint.'",';
520 }
521 3 $currentaction.='],';
522 }
523 else {
524 0 push(@errors, 'Invalid yaml : you try to use a hash inside another hash in '.$type.' action.');#error
525 }
526 }
527 11 $currentaction.='});'."\n";
528 11 ▶ if ($boolin) { $actionsin.=$currentaction; } else { $actionsout.=$currentaction; }
Branch: 1 branch
BranchTrueFalseTotal
if ($boolin) { } 6 5 11
529 }
530 ▶ elsif( ref($$intaction{$kint}) eq "" or ref($$intaction{$kint}) eq "SCALAR" ) {
Condition66%2/3
ref $intaction->{$kint} eq "" or ref $intaction->{$kint} eq "SCALAR"
l!l&&r!l&&!r
7701
MC/DC50%1/2
ref $intaction->{$kint} eq "" or ref $intaction->{$kint} eq "SCALAR"
ref $intaction->{$kint} eq "" ref $intaction->{$kint} eq "SCALAR"
Truth table66%2/3
A or B
A= ref $intaction->{$kint} eq ""B= ref $intaction->{$kint} eq "SCALAR"
ABresult
1X1
011
000
531 77 $currentaction="";
532 77 $boolin=0;
533 77 my $ftag;
534 my $stag;
535 77 ▶ if($kint=~/^\$f(\d{3})(\w)$/) {
Branch: 6 branches
BranchTrueFalseTotal
if ($kint =~ /^\$f(\d{3})(\w)$/) { } 8 69 77
elsif ($kint =~ /^\$i(\d{3})(\w)$/) { } 0 69 69
elsif ($kint =~ /^f(\d{3})(\w)$/) { } 50 19 69
elsif ($kint =~ /^i(\d{3})(\w)$/) { } 0 19 19
elsif ($kint =~ /^i(\d)$/) { } 0 19 19
elsif ($kint =~ /^(\w)$/) { } 19 0 19
536 8 $boolin=1;
537 8 $ftag='$f'.$1;
538 8 $stag=$2;
539 }
540 elsif($kint=~/^\$i(\d{3})(\w)$/) {
541 0 $boolin=1;
542 0 $ftag='$f'.$1;
543 0 $stag='µ';
544 0 ▶ $stag='µ' if($2 eq "1");
Branch: 1 branch
BranchTrueFalseTotal
if $2 eq 1 0 0 0
545 0 ▶ $stag='£' if($2 eq "2");
Branch: 1 branch
BranchTrueFalseTotal
if $2 eq 2 0 0 0
546 }
547 elsif($kint=~/^f(\d{3})(\w)$/) {
548 50 $ftag='"'.$1.'"';
549 50 $stag=$2;
550 }
551 elsif($kint=~/^i(\d{3})(\w)$/) {
552 0 $ftag='"'.$1.'"';
553 0 $stag='µ';
554 0 ▶ $stag='µ' if($2 eq "1");
Branch: 1 branch
BranchTrueFalseTotal
if $2 eq 1 0 0 0
555 0 ▶ $stag='£' if($2 eq "2");
Branch: 1 branch
BranchTrueFalseTotal
if $2 eq 2 0 0 0
556 }
557 elsif($kint=~/^i(\d)$/) {
558 0 $ftag='$$currentfield';
559 0 $stag='µ';
560 0 ▶ $stag='µ' if($1 eq "1");
Branch: 1 branch
BranchTrueFalseTotal
if $1 eq 1 0 0 0
561 0 ▶ $stag='£' if($1 eq "2");
Branch: 1 branch
BranchTrueFalseTotal
if $1 eq 2 0 0 0
562 0 $boolin=1;
563 }
564 elsif($kint=~/^(\w)$/) {
565 19 $ftag='$$currentfield';
566 19 $boolin=1;
567 19 $stag=$kint;
568 }
569 else {
570 0 push(@errors, 'Invalid yaml : your field reference is not valid in '.$type.' action.');#error
571 0 next;
572 }
573 77 $$intaction{$kint}=~s/"/\\"/g;
574 77 ▶ $boolin=1 if($$intaction{$kint}=~/\$f/);
Branch: 1 branch
BranchTrueFalseTotal
if $intaction->{$kint} =~ /\$f/ 6 71 77
575 77 $$intaction{$kint}=~s/\$this/tempnameforcurrentvalueofthissubfield/g;
576 77 $$intaction{$kint}=~s/\\&/temporarycallfunction/g;
577 77 $currentaction.=$specaction.'('.$ftag.',{"'.$stag.'"=>"'.$$intaction{$kint}.'"});'."\n";
578 77 ▶ if ($boolin) { $actionsin.=$currentaction; } else { $actionsout.=$currentaction; }
Branch: 1 branch
BranchTrueFalseTotal
if ($boolin) { } 31 46 77
579 }
580 elsif( ref($$intaction{$kint}) eq "ARRAY" ) {
581 1 $currentaction="";
582 1 $boolin=0;
583 1 my $ftag;
584 my $stag;
585 1 ▶ if($kint=~/^\$f(\d{3})(\w)$/) {
Branch: 5 branches
BranchTrueFalseTotal
if ($kint =~ /^\$f(\d{3})(\w)$/) { } 0 1 1
elsif ($kint =~ /^\$i(\d{3})(\w)$/) { } 0 1 1
elsif ($kint =~ /^f(\d{3})(\w)$/) { } 1 0 1
elsif ($kint =~ /^i(\d{3})(\w)$/) { } 0 0 0
elsif ($kint =~ /^(\w)$/) { } 0 0 0
586 0 $boolin=1;
587 0 $ftag='$f'.$1;
588 0 $stag=$2;
589 }
590 elsif($kint=~/^\$i(\d{3})(\w)$/) {
591 0 $boolin=1;
592 0 $ftag='$f'.$1;
593 0 $stag='µ';
594 0 ▶ $stag='µ' if($2 eq "1");
Branch: 1 branch
BranchTrueFalseTotal
if $2 eq 1 0 0 0
595 0 ▶ $stag='£' if($2 eq "2");
Branch: 1 branch
BranchTrueFalseTotal
if $2 eq 2 0 0 0
596 }
597 elsif($kint=~/^f(\d{3})(\w)$/) {
598 1 $ftag='"'.$1.'"';
599 1 $stag=$2;
600 }
601 elsif($kint=~/^i(\d{3})(\w)$/) {
602 0 $ftag='"'.$1.'"';
603 0 $stag='µ';
604 0 ▶ $stag='µ' if($2 eq "1");
Branch: 1 branch
BranchTrueFalseTotal
if $2 eq 1 0 0 0
605 0 ▶ $stag='£' if($2 eq "2");
Branch: 1 branch
BranchTrueFalseTotal
if $2 eq 2 0 0 0
606 }
607 elsif($kint=~/^(\w)$/) {
608 0 $ftag='$$currentfield';
609 0 $boolin=1;
610 0 $stag=$kint;
611 }
612 else {
613 0 push(@errors, 'Invalid yaml : your field reference is not valid in '.$type.' action.');#error
614 0 next;
615 }
616 1 $currentaction.=$specaction.'('.$ftag.',{"'.$stag.'"=>[';
617 1 foreach my $sintaction(@{$$intaction{$kint}}) {
618 2 $sintaction=~s/"/\\"/g;
619 2 ▶ $boolin=1 if($sintaction=~/\$f/);
Branch: 1 branch
BranchTrueFalseTotal
if $sintaction =~ /\$f/ 0 2 2
620 2 $sintaction=~s/\$this/tempnameforcurrentvalueofthissubfield/g;
621 2 $sintaction=~s/\\&/temporarycallfunction/g;
622 2 $currentaction.='"'.$sintaction.'",';
623 }
624 1 $currentaction.=']});'."\n";
625 0 ▶ if ($boolin) { $actionsin.=$currentaction; } else { $actionsout.=$currentaction; }
Branch: 1 branch
BranchTrueFalseTotal
if ($boolin) { } 0 1 1
626 }
627 }
628 }
629 else {
630 0 push(@errors, 'Invalid yaml : you try to use non hash context in '.$type.' action.');#error
631 }
632 }
633 elsif ($type eq "duplicatefield") {
634 6 ▶ if ( ref($intaction) eq "ARRAY" ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $intaction eq 'ARRAY') { } 3 3 6
elsif (ref $intaction eq '' or ref $intaction eq 'SCALAR') { } 3 0 3
635 3 foreach my $vint (@$intaction) {
636 7 ▶ if( ref($vint) eq "" or ref($vint) eq "SCALAR" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $vint eq '' or ref $vint eq 'SCALAR') { } 7 0 7
Condition33%1/3
ref $vint eq "" or ref $vint eq "SCALAR"
l!l&&r!l&&!r
700
MC/DC0%0/2
ref $vint eq "" or ref $vint eq "SCALAR"
ref $vint eq "" ref $vint eq "SCALAR"
Truth table33%1/3
A or B
A= ref $vint eq ""B= ref $vint eq "SCALAR"
ABresult
1X1
011
000
637 7 ▶ if($vint=~/^\$f(\d{3})\s?>\s?f(\d{3})$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($vint =~ /^\$f(\d{3})\s?>\s?f(\d{3})$/) { } 3 4 7
elsif ($vint =~ /^f(\d{3})\s?>\s?f(\d{3})$/) { } 4 0 4
638 3 ▶ if ($1 < "010" and $2 < "010" ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($1 < 10 and $2 < 10) { } 2 1 3
elsif ($1 >= 10 and $2 >= 10) { } 1 0 1
Condition66%2/3
$1 < "010" and $2 < "010"
!ll&&!rl&&r
102
MC/DC50%1/2
$1 < "010" and $2 < "010"
$1 < "010" $2 < "010"
Truth table66%2/3
A and B
A= $1 < "010"B= $2 < "010"
ABresult
0X0
100
111
639 2 $actionsin.='$record->insert_fields_ordered( MARC::Field->new( "'.$2.'", $f'.$1.'->data() ) );';
640 }
641 ▶ elsif ($1 >= "010" and $2 >= "010" ) {
Condition33%1/3
$1 >= "010" and $2 >= "010"
!ll&&!rl&&r
001
MC/DC0%0/2
$1 >= "010" and $2 >= "010"
$1 >= "010" $2 >= "010"
Truth table33%1/3
A and B
A= $1 >= "010"B= $2 >= "010"
ABresult
0X0
100
111
642 1 $actionsin.='my @dsubfields; foreach my $subfield ( $f'.$1.'->subfields() ) { push @dsubfields, ( $$subfield[0], $$subfield[1] );}'."\n";
643 1 $actionsin.='$record->insert_fields_ordered( MARC::Field->new( "'.$2.'", $f'.$1.'->indicator(1), $f'.$1.'->indicator(2), @dsubfields ) );';
644 }
645 else {
646 0 push(@errors, 'Invalid yaml : you want to duplicate a controlfield with a non-controlfield ');#error
647 }
648 }
649 elsif($vint=~/^f(\d{3})\s?>\s?f(\d{3})$/) {
650 4 ▶ if ($1 < "010" and $2 < "010" ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($1 < 10 and $2 < 10) { } 1 3 4
elsif ($1 >= 10 and $2 >= 10) { } 3 0 3
Condition66%2/3
$1 < "010" and $2 < "010"
!ll&&!rl&&r
301
MC/DC50%1/2
$1 < "010" and $2 < "010"
$1 < "010" $2 < "010"
Truth table66%2/3
A and B
A= $1 < "010"B= $2 < "010"
ABresult
0X0
100
111
651 1 $actionsout.=' for my $fielddup($record->field("'.$1.'")){';
652 1 $actionsout.='$record->insert_fields_ordered( MARC::Field->new( "'.$2.'", $fielddup->data() ) );';
653 1 $actionsout.='}'."\n";
654 }
655 ▶ elsif ($1 >= "010" and $2 >= "010" ) {
Condition33%1/3
$1 >= "010" and $2 >= "010"
!ll&&!rl&&r
003
MC/DC0%0/2
$1 >= "010" and $2 >= "010"
$1 >= "010" $2 >= "010"
Truth table33%1/3
A and B
A= $1 >= "010"B= $2 >= "010"
ABresult
0X0
100
111
656 3 $actionsout.=' for my $fielddup($record->field("'.$1.'")){';
657 3 $actionsout.='my @dsubfields; foreach my $subfield ( $fielddup->subfields() ) { push @dsubfields, ( $$subfield[0], $$subfield[1] );}'."\n";
658 3 $actionsout.='$record->insert_fields_ordered( MARC::Field->new( "'.$2.'", $fielddup->indicator(1), $fielddup->indicator(2), @dsubfields ) );';
659 3 $actionsout.='}'."\n";
660 }
661 else {
662 0 push(@errors, 'Invalid yaml : you want to duplicate a controlfield with a non-controlfield ');#error
663 }
664 }
665 else {
666 0 push(@errors, 'Invalid yaml : your field reference is not valid in '.$type.' action.');#error
667 }
668 }
669 else {
670 0 push(@errors, 'Invalid yaml : you try to use non scalar value in '.$type.' action.');#error
671 }
672 }
673 }
674 ▶ elsif ( ref($intaction) eq "" or ref($intaction) eq "SCALAR" ) {
Condition33%1/3
ref $intaction eq "" or ref $intaction eq "SCALAR"
l!l&&r!l&&!r
300
MC/DC0%0/2
ref $intaction eq "" or ref $intaction eq "SCALAR"
ref $intaction eq "" ref $intaction eq "SCALAR"
Truth table33%1/3
A or B
A= ref $intaction eq ""B= ref $intaction eq "SCALAR"
ABresult
1X1
011
000
675 3 my $vint=$intaction;
676 3 ▶ if($vint=~/^\$f(\d{3})\s?>\s?f(\d{3})$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($vint =~ /^\$f(\d{3})\s?>\s?f(\d{3})$/) { } 3 0 3
elsif ($vint =~ /^f(\d{3})\s?>\s?f(\d{3})$/) { } 0 0 0
677 3 ▶ if ($1 < "010" and $2 < "010" ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($1 < 10 and $2 < 10) { } 1 2 3
elsif ($1 >= 10 and $2 >= 10) { } 2 0 2
Condition66%2/3
$1 < "010" and $2 < "010"
!ll&&!rl&&r
201
MC/DC50%1/2
$1 < "010" and $2 < "010"
$1 < "010" $2 < "010"
Truth table66%2/3
A and B
A= $1 < "010"B= $2 < "010"
ABresult
0X0
100
111
678 1 $actionsin.='$record->insert_fields_ordered( MARC::Field->new( "'.$2.'", $f'.$1.'->data() ) );';
679 }
680 ▶ elsif ($1 >= "010" and $2 >= "010" ) {
Condition33%1/3
$1 >= "010" and $2 >= "010"
!ll&&!rl&&r
002
MC/DC0%0/2
$1 >= "010" and $2 >= "010"
$1 >= "010" $2 >= "010"
Truth table33%1/3
A and B
A= $1 >= "010"B= $2 >= "010"
ABresult
0X0
100
111
681 2 $actionsin.='my @dsubfields; foreach my $subfield ( $f'.$1.'->subfields() ) { push @dsubfields, ( $$subfield[0], $$subfield[1] );}'."\n";
682 2 $actionsin.='$record->insert_fields_ordered( MARC::Field->new( "'.$2.'", $f'.$1.'->indicator(1), $f'.$1.'->indicator(2), @dsubfields ) );';
683 }
684 else {
685 0 push(@errors, 'Invalid yaml : you want to duplicate a controlfield with a non-controlfield ');#error
686 }
687 }
688 elsif($vint=~/^f(\d{3})\s?>\s?f(\d{3})$/) {
689 0 ▶ if ($1 < "010" and $2 < "010" ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($1 < '010' and $2 < '010') { } 0 0 0
elsif ($1 >= '010' and $2 >= '010') { } 0 0 0
Condition0%0/3
$1 < "010" and $2 < "010"
!ll&&!rl&&r
000
MC/DC0%0/2
$1 < "010" and $2 < "010"
$1 < "010" $2 < "010"
Truth table0%0/3
A and B
A= $1 < "010"B= $2 < "010"
ABresult
0X0
100
111
690 0 $actionsout.=' for my $fielddup($record->field("'.$1.'")){';
691 0 $actionsout.='$record->insert_fields_ordered( MARC::Field->new( "'.$2.'", $fielddup->data() ) );';
692 0 $actionsout.='}'."\n";
693 }
694 ▶ elsif ($1 >= "010" and $2 >= "010" ) {
Condition0%0/3
$1 >= "010" and $2 >= "010"
!ll&&!rl&&r
000
MC/DC0%0/2
$1 >= "010" and $2 >= "010"
$1 >= "010" $2 >= "010"
Truth table0%0/3
A and B
A= $1 >= "010"B= $2 >= "010"
ABresult
0X0
100
111
695 0 $actionsout.=' for my $fielddup($record->field("'.$1.'")){';
696 0 $actionsout.='my @dsubfields; foreach my $subfield ( $fielddup->subfields() ) { push @dsubfields, ( $$subfield[0], $$subfield[1] );}'."\n";
697 0 $actionsout.='$record->insert_fields_ordered( MARC::Field->new( "'.$2.'", $fielddup->indicator(1), $fielddup->indicator(2), @dsubfields ) );';
698 0 $actionsout.='}'."\n";
699 }
700 else {
701 0 push(@errors, 'Invalid yaml : you want to duplicate a controlfield with a non-controlfield ');#error
702 }
703 }
704 else {
705 0 push(@errors, 'Invalid yaml : your field reference is not valid in '.$type.' action.');#error
706 }
707 }
708 else {
709 0 push(@errors, 'Invalid yaml : you try to use a hash value in '.$type.' action.');#error
710 }
711 }
712 elsif ($type eq "delete") {
713 12 ▶ if ( ref($intaction) eq "ARRAY" ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $intaction eq 'ARRAY') { } 3 9 12
elsif (ref $intaction eq '' or ref $intaction eq 'SCALAR') { } 9 0 9
714 3 foreach my $vint (@$intaction) {
715 6 ▶ if( ref($vint) eq "" or ref($vint) eq "SCALAR" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $vint eq '' or ref $vint eq 'SCALAR') { } 6 0 6
Condition33%1/3
ref $vint eq "" or ref $vint eq "SCALAR"
l!l&&r!l&&!r
600
MC/DC0%0/2
ref $vint eq "" or ref $vint eq "SCALAR"
ref $vint eq "" ref $vint eq "SCALAR"
Truth table33%1/3
A or B
A= ref $vint eq ""B= ref $vint eq "SCALAR"
ABresult
1X1
011
000
716 #print "$vint\n";
717 6 ▶ if($vint=~/^\$f(\d{3})(\w)$/) {
Branch: 5 branches
BranchTrueFalseTotal
if ($vint =~ /^\$f(\d{3})(\w)$/) { } 0 6 6
elsif ($vint =~ /^\$f(\d{3})$/) { } 0 6 6
elsif ($vint =~ /^f(\d{3})(\w)$/) { } 3 3 6
elsif ($vint =~ /^f(\d{3})$/) { } 3 0 3
elsif ($vint =~ /^(\w)$/) { } 0 0 0
718 0 $actionsin.=' if ( defined $f'.$1.'->subfield("'.$2.'") ) { if (scalar($f'.$1.'->subfields())==1) { $record->delete_field($f'.$1.'); } else { $f'.$1.'->delete_subfield(code => "'.$2.'"); } }'."\n";
719 }
720 elsif($vint=~/^\$f(\d{3})$/) {
721 0 $actionsin.=' $record->delete_field('.$vint.');'."\n";
722 }
723 elsif($vint=~/^f(\d{3})(\w)$/) {
724 3 $actionsout.=' for my $fieldel($record->field("'.$1.'")){if ( defined $fieldel->subfield("'.$2.'") ) { if (scalar($fieldel->subfields())==1) { $record->delete_field($fieldel); } else { $fieldel->delete_subfield(code => "'.$2.'"); } }}'."\n";
725 }
726 elsif($vint=~/^f(\d{3})$/) {
727 3 $actionsout.=' $record->delete_fields($record->field("'.$1.'"));'."\n";
728 }
729 elsif($vint=~/^(\w)$/) {
730 0 $actionsin.=' if ( defined $$currentfield->subfield("'.$vint.'") ) { if (scalar($$currentfield->subfields())==1) { $record->delete_field($$currentfield); } else { $$currentfield->delete_subfield(code => "'.$vint.'"); } }'."\n";
731 }
732 else {
733 0 push(@errors, 'Invalid yaml : your field reference is not valid in '.$type.' action.');#error
734 }
735 }
736 else {
737 0 push(@errors, 'Invalid yaml : you try to use non scalar value in '.$type.' action.');#error
738 }
739 }
740 }
741 ▶ elsif ( ref($intaction) eq "" or ref($intaction) eq "SCALAR" ) {
Condition33%1/3
ref $intaction eq "" or ref $intaction eq "SCALAR"
l!l&&r!l&&!r
900
MC/DC0%0/2
ref $intaction eq "" or ref $intaction eq "SCALAR"
ref $intaction eq "" ref $intaction eq "SCALAR"
Truth table33%1/3
A or B
A= ref $intaction eq ""B= ref $intaction eq "SCALAR"
ABresult
1X1
011
000
742 9 my $vint=$intaction;
743 9 ▶ if($vint=~/^\$f(\d{3})(\w)$/) {
Branch: 5 branches
BranchTrueFalseTotal
if ($vint =~ /^\$f(\d{3})(\w)$/) { } 1 8 9
elsif ($vint =~ /^\$f(\d{3})$/) { } 1 7 8
elsif ($vint =~ /^f(\d{3})(\w)$/) { } 2 5 7
elsif ($vint =~ /^f(\d{3})$/) { } 3 2 5
elsif ($vint =~ /^(\w)$/) { } 2 0 2
744 1 $actionsin.=' if ( defined $f'.$1.'->subfield("'.$2.'") ) { if (scalar($f'.$1.'->subfields())==1) { $record->delete_field($f'.$1.'); } else { $f'.$1.'->delete_subfield(code => "'.$2.'"); } }'."\n";
745 }
746 elsif($vint=~/^\$f(\d{3})$/) {
747 1 $actionsin.=' $record->delete_field('.$vint.');'."\n";
748 }
749 elsif($vint=~/^f(\d{3})(\w)$/) {
750 2 $actionsout.=' for my $fieldel($record->field("'.$1.'")){if ( defined $fieldel->subfield("'.$2.'") ) { if (scalar($fieldel->subfields())==1) { $record->delete_field($fieldel); } else { $fieldel->delete_subfield(code => "'.$2.'"); } }}'."\n";
751 }
752 elsif($vint=~/^f(\d{3})$/) {
753 3 $actionsout.=' $record->delete_fields($record->field("'.$1.'"));'."\n";
754 }
755 elsif($vint=~/^(\w)$/) {
756 2 $actionsin.=' if ( defined $$currentfield->subfield("'.$vint.'") ) { if (scalar($$currentfield->subfields())==1) { $record->delete_field($$currentfield); } else { $$currentfield->delete_subfield(code => "'.$vint.'"); } }'."\n";
757 }
758 else {
759 0 push(@errors, 'Invalid yaml : your field reference is not valid in '.$type.' action.');#error
760 }
761 }
762 else {
763 0 push(@errors, 'Invalid yaml : you try to use a hash value in '.$type.' action.');#error
764 }
765 }
766 elsif ($type eq "execute") {
767 7 ▶ if( ref($intaction) eq "" or ref($intaction) eq "SCALAR" ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $intaction eq '' or ref $intaction eq 'SCALAR') { } 7 0 7
elsif (ref $intaction eq 'ARRAY') { } 0 0 0
Condition33%1/3
ref $intaction eq "" or ref $intaction eq "SCALAR"
l!l&&r!l&&!r
700
MC/DC0%0/2
ref $intaction eq "" or ref $intaction eq "SCALAR"
ref $intaction eq "" ref $intaction eq "SCALAR"
Truth table33%1/3
A or B
A= ref $intaction eq ""B= ref $intaction eq "SCALAR"
ABresult
1X1
011
000
768 7 ▶ if($intaction=~/\$(f|i)(\d{3})/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($intaction =~ /\$(f|i)(\d{3})/) { } 0 7 7
769 0 $actionsin.=' eval ('.$intaction.');';
770 }
771 else {
772 7 $actionsout.=' eval ('.$intaction.');';
773 }
774 }
775 elsif( ref($intaction) eq "ARRAY" ) {
776 0 foreach my $sintaction(@$intaction) {
777 0 ▶ if($sintaction=~/\$(f|i)(\d{3})/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sintaction =~ /\$(f|i)(\d{3})/) { } 0 0 0
778 0 $actionsin.=' eval ('.$sintaction.');';
779 }
780 else {
781 0 $actionsout.=' eval ('.$sintaction.');';
782 }
783 }
784 }
785 else {
786 0 push(@errors, 'Invalid yaml : you try to use a hash value in '.$type.' action.');#error
787 }
788 }
789 else {
790 0 push(@errors, 'Invalid yaml : this action : '.$type.' is not valid.');#error
791 }
792 84 return ($actionsin,$actionsout);
793 }
794  
795 80 ▶sub testrule {
Subroutine testrule: called CC=21 SCAR=30.4
Pod undocumented
796 80 my ($rul, $actionsin, $actionsinter, $actionsout, $subs) = @_;
797 80 $globalcondition="";
798 80 ▶ $subs="no warnings 'redefine';".$subs if $subs ne "";
Branch: 1 branch
BranchTrueFalseTotal
if $subs ne "" 7 73 80
799 80 my $globalconditionstart='{ '."\n".$subs."\n".'my $boolcond=0;my $boolcondint=0;my $currentfield;no warnings \'substr\';no warnings \'uninitialized\';no warnings \'portable\';'."\n";
800 80 my $globalconditionint="";
801 80 my $globalconditionend="";#print Data::Dumper::Dumper ($rul);
802 80 ▶ if ( defnonull ( $$rul{'condition'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defnonull($rul->{'condition'})) { } 60 20 80
803 60 my @listconditiontags=grep( $_ , map({ $_=~/^(f|i)(\d{3})(.*)$/;$2 } (split(/\$/,$$rul{'condition'}))));#print $$rul{'condition'};
804 0 ▶ my @listconditionsubtags=grep( $_ , map({ if($_=~/^(f)(\d{3}\w)(.*)$/){$2}elsif($_=~/^(i)(\d{3})(.*)$/){$2} } (split(/\$/,$$rul{'condition'}))));
Branch: 2 branches
BranchTrueFalseTotal
if ($_ =~ /^(f)(\d{3}\w)(.*)$/) { } 68 86 154
elsif ($_ =~ /^(i)(\d{3})(.*)$/) { } 0 86 86
805 60 my %tag_names = map( { $_ => 1 } @listconditiontags);
806 60 my %tag_list;
807 60 @listconditiontags = keys(%tag_names);
808 60 foreach my $tag(@listconditiontags) {
809 68 $tag_list{$tag}=[];
810 68 foreach my $subtag(@listconditionsubtags) {
811 88 ▶ if (substr($subtag,0,3) eq $tag) {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($subtag, 0, 3) eq $tag) 68 20 88
812 68 ▶ if(length($subtag) == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $subtag == 3) { } 0 68 68
813 0 push (@{$tag_list{$tag}}, "tempvalueforcurrentfield");
814 }
815 else {
816 68 push (@{$tag_list{$tag}}, substr($subtag,3,1));
817 }
818 }
819 }
820 }
821 60 my $condition=$$rul{'condition'};
822 60 $condition=~s/(\$ldr(\d{1,2}))/\(substr\(\$record->leader\(\),$2,1)\)/g;
823 60 $condition=~s/(\$ldr)/(\$record->leader\(\)\)/g;
824 60 $condition=~s/(\$f\d{3})(\w)/defined($1$2) and $1$2/g;
825 60 $condition=~s/(\$f\d{3})(\w)(\d{1,2})/\(substr($1$2,$3,1\)\)/g;
826 60 $condition=~s/(\$f\d{3})(\w)/$1$2/g;#I can't remember why I did this
827 60 $condition=~s/(\$i(\d{3}))(\d)/\(\$f$2->indicator\($3\)\)/g;
828 60 my $booltagrule=0;
829 60 my $boolsubtagrule=0;
830 60 foreach my $tag (sort {$a cmp $b} keys(%tag_list)) {
831 68 my %tag_listtag = map { $_, 1 } @{$tag_list{$tag}};
832 68 $boolsubtagrule=0;
833 68 my @tag_listtagunique = keys %tag_listtag;
834 68 $globalconditionstart.='my $f'.$tag.';';
835 68 foreach my $subtag (@tag_listtagunique) {
836 63 my $matchdelaration='my \$f'.$tag.$subtag.';';
837 63 ▶ $globalconditionstart.='my $f'.$tag.$subtag.';' if $globalconditionstart!~$matchdelaration;
Branch: 1 branch
BranchTrueFalseTotal
unless $globalconditionstart =~ /$matchdelaration/ 63 0 63
838 }
839 68 ▶ if ( defined $record->field($tag) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $record->field($tag)) 66 2 68
840 66 $booltagrule=1;
841 66 $globalconditionint.="\n".'for $f'.$tag.' ( $record->field("'.$tag.'") ) {'."\n".'$currentfield=\$f'.$tag.';'."\n";
842 66 foreach my $subtag (@tag_listtagunique) {
843 62 $boolsubtagrule=1;
844 62 ▶ if ($subtag ne "tempvalueforcurrentfield" and $tag >= "010") {
Branch: 2 branches
BranchTrueFalseTotal
if ($subtag ne 'tempvalueforcurrentfield' and $tag >= 10) { } 58 4 62
elsif ($subtag ne 'tempvalueforcurrentfield') { } 4 0 4
Condition66%2/3
$subtag ne "tempvalueforcurrentfield" and $tag >= "010"
!ll&&!rl&&r
0458
MC/DC50%1/2
$subtag ne "tempvalueforcurrentfield" and $tag >= "010"
$subtag ne "tempvalueforcurrentfield" $tag >= "010"
Truth table66%2/3
A and B
A= $subtag ne "tempvalueforcurrentfield"B= $tag >= "010"
ABresult
0X0
100
111
845 58 $globalconditionint.='for $f'.$tag.$subtag.' ( $f'.$tag.'->subfield("'.$subtag.'"), my $tmpintesta=1 ) { my $tmpintestb=0; if ($tmpintesta==1) { $tmpintesta=undef;$tmpintestb=1; }'."\n";
846 58 $globalconditionint.='if ('.$condition.') {$boolcond=1;$boolcondint=1; eval{'.$actionsin.'}}else{$boolcondint=0 unless (!defined($tmpintesta) and $tmpintestb==0 );}'."\n";
847 58 $globalconditionend.='}'."\n";
848 }
849 elsif ($subtag ne "tempvalueforcurrentfield") {
850 4 $globalconditionint.='$f'.$tag.$subtag.' = $f'.$tag.'->data(); '."\n";
851 4 $globalconditionint.='if ('.$condition.') {$boolcond=1;$boolcondint=1; eval{'.$actionsin.'}}else{$boolcondint=0;}'."\n";
852 }
853 }
854 66 ▶ $globalconditionint.='if ('.$condition.')'."\n".'{$boolcond=1;$boolcondint=1; eval{'.$actionsin.'}}else{$boolcondint=0;}' unless $boolsubtagrule;
Branch: 1 branch
BranchTrueFalseTotal
unless $boolsubtagrule 10 56 66
855 66 $globalconditionend.='if ($boolcondint){ eval{'.$actionsinter.'};}}'."\n";
856 }#else { $globalconditionint.='if ('.$condition.') {$boolcond=1;$boolcondint=1; eval{'.$actionsin.'}}else{$boolcondint=0;}'."\n"; }
857 }
858 60 ▶ $globalconditionint.='if ('.$condition.')'."\n".'{$boolcond=1;$boolcondint=1; eval{'.$actionsin.'}}else{$boolcondint=0;}' unless $booltagrule;
Branch: 1 branch
BranchTrueFalseTotal
unless $booltagrule 5 55 60
859 60 $globalconditionend.="\n".' if ($boolcond){eval{'.$actionsout.'}}'."\n".' return $boolcond;}';#if ($boolcond or ('.$condition.'))
860 60 $globalcondition=$globalconditionstart.$globalconditionint.$globalconditionend;
861 60 ▶ print "\n--------globalcondition----------\n$globalcondition\n---------globalcondition---------\n" if $verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose 0 60 60
862 0 ▶ return eval($globalcondition);
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine convertbaddate: called CC=5 SCAR=16.1
Subroutine fromo2e: called CC=1 SCAR=0.0
Subroutine return_record_encoding: called CC=1 SCAR=0.0
Subroutine return_record_encoding: called CC=1 SCAR=0.0
Subroutine sub1: called CC=1 SCAR=0.0
Subroutine sub1: called CC=1 SCAR=0.0
Subroutine trim: called CC=1 SCAR=0.0
Subroutine warnfoo: not called CC=1 SCAR=0.0
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Branch: 4 branches
BranchTrueFalseTotal
if ($in =~ m[^(\d{1,2})/(\d{1,2})/(\d{2}).*]) { } 1 0 1
if ($day =~ /^\d$/) 1 0 1
if ($month =~ /^\d$/) 0 1 1
if (int $year > 13) { } 0 1 1
863 }
864 else {
865 20 ▶ print "\n--------actionsout----------\n$globalconditionstart$actionsout}\n---------actionsout---------\n" if $verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose 0 20 20
866 1 ▶ eval($globalconditionstart.$actionsout.'}');
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine test20a: called CC=1 SCAR=0.0
Subroutine test24a: called CC=1 SCAR=0.0
Subroutine test24a: called CC=1 SCAR=0.0
Pod undocumented
Pod undocumented
Pod undocumented
867 20 return 1;
868 }
869 0 return 1;
870 }
871  
872 58 ▶sub ReplaceAllInRecord {
Subroutine ReplaceAllInRecord: called CC=11 SCAR=24.0
Pod undocumented
873 58 my ($pos) = @_;
874 58 ▶ return unless ( $record && $record->fields() );
Branch: 1 branch
BranchTrueFalseTotal
unless $record and $record->fields 2 56 58
Condition66%2/3
$record and $record->fields
!ll&&!rl&&r
0256
MC/DC50%1/2
$record and $record->fields
$record $record->fields
Truth table66%2/3
A and B
A= $recordB= $record->fields
ABresult
0X0
100
111
875 56 foreach my $field ( $record->fields() ) {
876 207 my @subfields;
877 207 ▶ if(!$field->is_control_field()) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $field->is_control_field) { } 178 29 207
878 178 ▶ if (scalar($field->subfields()) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar $field->subfields > 0) 177 1 178
879 177 foreach my $subfield ( $field->subfields() ) {
880 361 my $newval=$$subfield[1];
881 361 ▶ if ($pos eq "before") {
Branch: 2 branches
BranchTrueFalseTotal
if ($pos eq 'before') { } 153 208 361
elsif ($pos eq 'after') { } 208 0 208
882 #$newval=~s/\$/#_dollarsd_#/g;#to force warn
883 153 $newval=~s/\$/#_dollars_#/g;
884 153 $newval=~s/"/#_dbquote_#/g;
885 }
886 elsif ($pos eq "after") {
887 208 $newval=~s/#_dollars_#/\$/g;
888 208 $newval=~s/#_dbquote_#/"/g;
889 }
890 361 push @subfields, ( $$subfield[0], $newval );
891 }
892 177 my $newfield = MARC::Field->new( $field->tag(), $field->indicator(1), $field->indicator(2), @subfields );
893 177 $field->replace_with($newfield);
894 }
895 }
896 else {
897 29 my $newval=$field->data();
898 29 ▶ if ($pos eq "before") {
Branch: 2 branches
BranchTrueFalseTotal
if ($pos eq 'before') { } 12 17 29
elsif ($pos eq 'after') { } 17 0 17
899 12 $newval=~s/\$/#_dollars_#/g;
900 12 $newval=~s/"/#_dbquote_#/g;
901 }
902 elsif ($pos eq "after") {
903 17 $newval=~s/#_dollars_#/\$/g;
904 17 $newval=~s/#_dbquote_#/"/g;
905 }
906 29 $field->update($newval);
907 }
908 }
909 }
910  
911 1 1;
912 __END__
↑ Summary