lib/MARC/Transform.pm

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