blib/lib/MAB2/Record/Base.pm

filter: Statementstmt 87.2% 192 / 220 Branchbran 76.3% 55 / 72 Conditioncond 66.6% 6 / 9 MC/DCmcdc 50.0% 3 / 6 Subroutinesub 75.0% 15 / 20 Podpod 0.0% 0 / 10 totaltotal 80.4% 271 / 337 CC 52 SCAR 29.3
CC
52
Cov
84%
parsedoc
33.0
_struct
12.9
date_004
12.0
CRAP 18.7
↑ Summary blib/lib/Encode/MAB2.pm »
1 package MAB2::Record::Base;
2 2 our $VERSION = '0.03';
3  
4 2 ▶use Encode::MAB2;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head1 NAME
7  
8 MAB2::Record::Base - Access an MAB2 record
9  
10 =head1 SYNOPSIS
11  
12 use MAB2::Record::Base;
13  
14 # Constructor
15 my $mab2raw = "00296nM2.01200024 k001 1000016-1\c^002a19890418".
16 "\c^004 20010812\c^028b1000016-1\c^029 HK00158537\c^030 aa1dc".
17 "|m\c^036aIT\c^066 |\c^070 9002\c^070aHBZ\c^800 Accademia Na".
18 "zionale di San Luca <Roma>\c^810 Accademia di San Luca <Roma, A".
19 "ccademia Nazionale di San Luca>\c^850aReale Accademia di San Lu".
20 "ca <Roma>\c^852a45335-3\c^\c]";
21 my $mab2 = MAB2::Record::Base->new($mab2raw);
22 # $mab2 now blessed into MAB2::Record::gkd because it is a gkd record
23  
24 # various representations:
25 print $mab2->id; # just the ID
26 print $mab2->readable; # quite readable
27 print $mab2->as_string; # the raw string we put into it
28 print $mab2->dump; # only useful for debugging the module itself
29  
30  
31 =head1 DESCRIPTION
32  
33 C<MAB2::Record::Base> is the common base class for all classes
34 implementing MAB2 record types:
35  
36 MAB2::Record::gkd
37 MAB2::Record::lokal
38 MAB2::Record::pnd
39 MAB2::Record::swd
40 MAB2::Record::titel
41  
42 The constructor C<new> takes a raw MAB2 record as argument and returns
43 an object which is blessed into one of the five above listed classes.
44 Some level of proficiency in dealing with MAB2 records is needed for
45 the user of this module for further processing of the objects. It is
46 recommended to use C<Data::Dumper> to get acquainted with the raw format
47 of the created objects.
48  
49 For illustration purpose, here is the Data::Dumper output of the full
50 object into which the sample record from the SYNOPSIS section is
51 transformed:
52  
53 $VAR1 = bless( [
54 '...',
55 undef,
56 [
57 {
58 'nicht_benutzt' => [
59 ' '
60 ],
61 'datenanfangsadresse' => [
62 '00024'
63 ],
64 'satztyp' => [
65 'k',
66 'Koerperschaftsnamensatz (MAB-GKD)'
67 ],
68 'versionsangabe' => [
69 'M2.0'
70 ],
71 'satzstatus' => [
72 'n',
73 'neuer Datensatz'
74 ],
75 'indikatorlaenge' => [
76 '1'
77 ],
78 'satzlaenge' => [
79 '00296'
80 ],
81 'teilfeldkennungslaenge' => [
82 '2'
83 ]
84 },
85 [
86 [
87 '001',
88 ' ',
89 '1000016-1',
90 'identifikationsnummer des datensatzes'
91 ],
92 [
93 '002',
94 'a',
95 '19890418',
96 'datum der ersterfassung / fremddatenuebernahme'
97 ],
98 [
99 '004',
100 ' ',
101 '20010812',
102 'erstellungsdatum des austauschsatzes'
103 ],
104 ...
105 [
106 '810',
107 ' ',
108 'Accademia di San Luca <Roma, Accademia Nazionale di San
109 Luca>',
110 '1. verweisungsform zum namen der koerperschaft'
111 ],
112 [
113 '850',
114 'a',
115 'Reale Accademia di San Luca <Roma>',
116 '1. frueherer, zeitweiser oder spaeterer name der koerper
117 schaft'
118 ],
119 [
120 '852',
121 'a',
122 '45335-3',
123 'identifikationsnummer des 1. frueheren, zeitweisen oder
124 spaeteren namens'
125 ]
126 ]
127 ],
128 '...'
129 ], 'MAB2::Record::gkd' );
130  
131  
132 Please note that the object contains both the original string in its
133 own byte oriented encoding and all fields in Unicode. The conversion
134 is done by the C<Encode::MAB2> module.
135  
136 The normal way of accessing MAB2 records is through the use of either
137 the C<Tie::MAB2::Recno> or C<Tie::MAB2::Id> class. The C<Tie::MAB2::Recno>
138 class binds an MAB2 file to an array and each record in the original
139 MAB2 file to an array element starting with element 0. The
140 C<Tie::MAB2::Id> class binds to a hash with the MAB2 identifier as the
141 key.
142  
143 =head1 Overloading
144  
145 The tied objects have their stringifier overloaded to the
146 C<as_string()> method so that
147  
148 print $tie[1234];
149  
150 always prints the record as the unaltered original input record.
151  
152 =head1 SEE ALSO
153  
154 C<Encode::MAB2>, C<Tie::MAB2::Recno>, C<Tie::MAB2::Id>
155  
156  
157 =cut
158  
159 2 ▶use constant RAW => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
160 2 ▶use constant INTERNALS => 1; # maybe nonsense: sometimes recno,
Subroutine BEGIN: called CC=1 SCAR=0.0
161 # sometimes id, whatever the *caller*
162 # wants to have there
163 2 ▶use constant STRUCT => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
164 2 ▶use constant DUMPVALUE => 3;
Subroutine BEGIN: called CC=1 SCAR=0.0
165  
166 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
167 2 ▶use overload '""' => "as_string";
Subroutine BEGIN: called CC=1 SCAR=0.0
168  
169 2 ▶use Dumpvalue;
Subroutine BEGIN: called CC=1 SCAR=0.0
170 2 our $DV = Dumpvalue->new(unctrl => "quote");
171  
172 2 our $DEBUG;
173 2 ▶$DEBUG = 1 unless defined $DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $MAB2::Record::Base::DEBUG 2 0 2
174 2 our $NAMESPACE = "MAB2::Record";
175 2 my $KDocs;
176 my $RDocs;
177 2 our(%type2pack) = qw(
178 h titel
179 y titel
180 u titel
181 v titel
182 p pnd
183 t pnd
184 k gkd
185 w gkd
186 r swd
187 s swd
188 x swd
189 l lokal
190 e lokal
191 z lokal
192 );
193  
194 {
195 2 local $/;
196 2 my $strdocs = <DATA>;
197 2 close DATA;
198 2 ($KDocs, $RDocs) = __PACKAGE__->parsedoc($strdocs);
199 }
200  
201 {
202 2 my %seen;
203 2 for my $pack (grep !$seen{$_}++, values %type2pack) {
204 10 my $req = "MAB2/Record/$pack.pm";
205 10 require $req;
206 }
207 }
208  
209 12 ▶sub parsedoc {
Subroutine parsedoc: called CC=33 SCAR=35.0
Pod undocumented
210 12 my $self = shift;
211 12 my $strdocs = shift;
212  
213 12 $strdocs =~ s/ ^ .*?\n (?=\d ) //sx; # remove header
214  
215 12 my @docs = $strdocs =~ /\G(\d.*?\n)(?=\d|$)/sgc; # split into subdocuments
216 12 my @kennungdocs;
217 my @realrecdocs;
218 12 for my $doc (@docs) {
219 1162 $doc =~ s/\s+\z//;
220 1162 ▶ if ($doc =~ /^\d\d?\s/) {
Branch: 3 branches
BranchTrueFalseTotal
if ($doc =~ /^\d\d?\s/) { } 16 1146 1162
elsif ($doc =~ /^\d\d\d-/) { } 148 998 1146
elsif ($doc =~ /^\d--/) { } 28 970 998
221 16 push @kennungdocs, [$doc];
222 } elsif ($doc =~ /^\d\d\d-/) {
223 148 next;
224 } elsif ($doc =~ /^\d--/) {
225 28 next;
226 } else {
227 970 push @realrecdocs, [$doc];
228 }
229 }
230 12 my %seen = ();
231 12 for my $k (0..$#kennungdocs) {
232 16 my $kdoc = $kennungdocs[$k];
233 16 my $doc = $kdoc->[0];
234 16 my($line1,$kexplain) = $doc =~ /(^[^\n]+)(?:\n(.+))?/s;
235 # print "line1: $line1\n";
236 16 my($start,$to,$name) = $line1 =~ m{ ^ (\d+) (.{8}) \s+ (.*) }x; #
237 16 my $length = 0;
238 16 ▶ if ($to =~ /-\s(\d+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($to =~ /-\s(\d+)/) 8 8 16
239 8 $length = $1 - $start;
240 }
241 16 $length++; # 0->1, 4->5 :-)
242 16 $name = lc $name;
243 16 $name =~ s/[^a-z0-9_]/_/g;
244 16 ▶ die if $seen{$name}++;
Branch: 1 branch
BranchTrueFalseTotal
if $seen{$name}++ 0 16 16
245 # print "start: $start\n";
246 # print "name: $name\n";
247 # print "kexplain: $kexplain\n" if defined $kexplain;
248 16 my %kexplain;
249 16 ▶ if ($kexplain && length $kexplain) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kexplain and length $kexplain) 4 12 16
Condition66%2/3
$kexplain and length $kexplain
!ll&&!rl&&r
1204
MC/DC50%1/2
$kexplain and length $kexplain
$kexplain length $kexplain
Truth table66%2/3
A and B
A= $kexplainB= length $kexplain
ABresult
0X0
100
111
250 4 my @code = $kexplain =~ /\G\s+([a-z])\s=\s(.*?)(?=\n\s+[a-z]\s=\s|$)/sgc;
251 4 %kexplain = @code;
252 4 for my $e (keys %kexplain) {
253 44 $kexplain{$e} =~ s/^\s+//;
254 44 $kexplain{$e} =~ s/\s+$//;
255 44 $kexplain{$e} =~ s/\s+/ /gs;
256 # print "ex $e: $kexplain{$e}\n";
257 }
258 }
259 16 $kdoc->[1] = $start;
260 16 $kdoc->[2] = $length;
261 16 $kdoc->[3] = $name; # all uppercase hurts
262 16 $kdoc->[4] = \%kexplain;
263 }
264 12 %seen = ();
265 12 local $| = 1;
266 12 for my $r (0..$#realrecdocs) {
267 970 my $rdoc = $realrecdocs[$r];
268 970 my $doc = $rdoc->[0];
269 # print "========>\n", $doc, "\n<========";
270  
271 # very different from above, because "line1" can be more than one line
272 970 my($line1,$rexplain) = $doc =~ /^((?:[^\n]|\n(?!\n))+)(?:\n\n(.+))?/s;
273 970 $line1 =~ s/^\s+//;
274 970 $line1 =~ s/\s+$//;
275 970 $line1 =~ s/\s+/ /g;
276 970 $line1 =~ s/^(\d+)\s+//;
277 970 my($codenr) = $1;
278 970 ▶ die "seeing again $codenr???" if $seen{$codenr}++;
Branch: 1 branch
BranchTrueFalseTotal
if $seen{$codenr}++ 0 970 970
279 970 ▶ if ($rexplain) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rexplain) { } 628 342 970
280 # $rexplain =~ s/^\s+Indikator:\s+//g;
281 628 $rexplain =~ s/^\s+//g;
282 } else {
283 342 $rexplain = "";
284 }
285 # print "self[$self]codenr[$codenr]rexplain[$rexplain]\n" if defined $rexplain;
286 970 $rdoc->[1] = $codenr;
287 970 $rdoc->[2] = undef;
288 970 $rdoc->[3] = $line1;
289 970 $rdoc->[4] = $rexplain; # XXX this needs to become more useful
290 # than just plain text
291 }
292 12 my $end = $#realrecdocs;
293 12 for my $r (0..$end) {
294 970 ▶ next unless $realrecdocs[$r][4] && $realrecdocs[$r][4] eq "...";
Branch: 1 branch
BranchTrueFalseTotal
unless $realrecdocs[$r][4] and $realrecdocs[$r][4] eq "..." 948 22 970
Condition100%3/3
$realrecdocs[$r][4] and $realrecdocs[$r][4] eq "..."
!ll&&!rl&&r
34260622
MC/DC100%2/2
$realrecdocs[$r][4] and $realrecdocs[$r][4] eq "..."
$realrecdocs[$r][4] $realrecdocs[$r][4] eq "..."
Truth table100%3/3
A and B
A= $realrecdocs[$r][4]B= $realrecdocs[$r][4] eq "..."
ABresult
0X0
100
111
295 22 my $after_yadda = $realrecdocs[$r+1][1];
296 # print "Found >>...<< in $realrecdocs[$r][1], need to fill upto $after_yadda";
297  
298 # Ich will vielleicht eine Zahl in diesem Text hochzaehlen
299 22 ▶ if (my($foundnumber) = $realrecdocs[$r][3] =~ /(\d+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($foundnumber) = $realrecdocs[$r][3] =~ /(\d+)/) { } 18 4 22
300 18 my $step = 1;
301 18 my $rr3 = $realrecdocs[$r][3];
302 18 ▶ if ($rr3 eq "ZUSAETZLICHE ANGABEN ZUR 2. VERWEISUNGSFORM") {
Branch: 7 branches
BranchTrueFalseTotal
if ($rr3 eq 'ZUSAETZLICHE ANGABEN ZUR 2. VERWEISUNGSFORM') { } 2 16 18
elsif ($rr3 eq 'IDENTIFIKATIONSNUMMER DES 2. FRUEHEREN, ZEITWEISEN ODER SPAETEREN NAMENS DER KOERPERSCHAFT') { } 2 14 16
elsif ($rr3 eq 'ERLAEUTERUNGEN ZUR 2. SCHLAGWORTKETTE') { } 6 8 14
elsif ($rr3 eq 'KOERPERSCHAFT, BEI DER DIE 2. PERSON BESCHAEFTIGT IST') { } 2 6 8
elsif ($rr3 eq 'IDENTIFIKATIONSNUMMER DES KOERPERSCHAFTSNAMENSATZES DER 2. KOERPERSCHAFT') { } 2 4 6
elsif ($rr3 eq 'ZUSAETZE ZUM 2. PARALLELSACHTITEL') { } 2 2 4
elsif ($rr3 eq 'SACHTITEL DER 2. NE') { } 2 0 2
303 2 $step = 2;
304 } elsif ($rr3 eq "IDENTIFIKATIONSNUMMER DES 2. FRUEHEREN, ZEITWEISEN ODER SPAETEREN NAMENS DER KOERPERSCHAFT") {
305 # gkd
306 2 $step = 3;
307 } elsif ($rr3 eq "ERLAEUTERUNGEN ZUR 2. SCHLAGWORTKETTE") {
308 6 $step = 5;
309 } elsif ($rr3 eq "KOERPERSCHAFT, BEI DER DIE 2. PERSON BESCHAEFTIGT IST") {
310 2 $step = 4;
311 } elsif ($rr3 eq "IDENTIFIKATIONSNUMMER DES KOERPERSCHAFTSNAMENSATZES DER 2. KOERPERSCHAFT") {
312 2 $step = 2;
313 } elsif ($rr3 eq "ZUSAETZE ZUM 2. PARALLELSACHTITEL") {
314 2 $step = 4;
315 } elsif ($rr3 eq "SACHTITEL DER 2. NE") {
316 2 $step = 6;
317 }
318 18 my $before_yadda = $realrecdocs[$r][1];
319 18 for my $offset (1..$step) {
320 # warn "offset[$offset]";
321 72 my $first = $before_yadda + $offset;
322 72 my $blueprint = $first - $step;
323 # warn "first[$first]blueprint[$blueprint]";
324 72 my $blueprintrec;
325 72 for my $rr (@realrecdocs) {
326 # warn "DEBUG: rr1[$rr->[1]]";
327 7792 ▶ next unless $rr->[1] == $blueprint;
Branch: 1 branch
BranchTrueFalseTotal
unless $rr->[1] == $blueprint 7726 66 7792
328 66 $blueprintrec = $rr;
329 66 last;
330 }
331 72 ▶ next unless $blueprintrec;
Branch: 1 branch
BranchTrueFalseTotal
unless $blueprintrec 6 66 72
332 66 ▶ die "Unexpected blueprintrec3[$blueprintrec->[3]]"
Branch: 1 branch
BranchTrueFalseTotal
unless $blueprintrec->[3] =~ /2/ 0 66 66
333 unless $blueprintrec->[3] =~ /2/;
334 66 my $sprintf = $blueprintrec->[3];
335 66 $sprintf =~ s/2/%d/;
336 66 my $foundnumber = 2;
337 66 ▶ for (my $nr = $first; $nr<$after_yadda; $nr+=$step) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nr < $after_yadda) 694 66 760
338 694 push @realrecdocs, [
339 ">>>generated<<<",
340 sprintf("%03d", $nr),
341 undef,
342 sprintf($sprintf,++$foundnumber),
343 undef
344 ];
345 }
346 }
347 } else {
348 4 for my $i ($realrecdocs[$r][1]+1..$after_yadda-1) { # $after_yadda (sans -1) XXX
349 16 push @realrecdocs, [
350 ">>>same as $realrecdocs[$r][1]<<<",
351 sprintf("%03d", $i),
352 undef,
353 $realrecdocs[$r][3],
354 undef
355 ];
356 }
357 }
358 }
359 # Now realrecdocs is unsorted, but we prefer it as a hash anyway
360 12 my %realrecdocs;
361 12 for my $rdoc (@realrecdocs) {
362 1680 $realrecdocs{$rdoc->[1]} = $rdoc;
363 }
364  
365 12 return(\@kennungdocs,\%realrecdocs);
366 }
367  
368 2 ▶sub new {
Subroutine new: called CC=3 SCAR=12.3
Pod undocumented
369 2 my($me,$raw,$key) = @_;
370 2 ▶ my $self = bless [$raw,$key], ref $me || $me;
Condition33%1/3
ref $me || $me
l!l&&r!l&&!r
020
MC/DC0%0/2
ref $me || $me
ref $me $me
Truth table33%1/3
A || B
A= ref $meB= $me
ABresult
1X1
011
000
371 2 ▶ if ( my $pack = $self->_class() ) { # was $struct->[0]{satztyp}[0]
Branch: 1 branch
BranchTrueFalseTotal
if (my $pack = $self->_class) { } 2 0 2
372 2 bless $self, "MAB2::Record::$pack";
373 } else {
374 0 die "Couldn't determine class.";
375 }
376 2 $self;
377 }
378  
379 1 ▶sub as_string {
Subroutine as_string: called CC=1 SCAR=0.0
Pod undocumented
380 1 my($self) = @_;
381 1 $self->[RAW];
382 }
383  
384 2 ▶sub readable {
Subroutine readable: called CC=4 SCAR=13.9
Pod undocumented
385 2 my($self) = @_;
386 2 $self->_struct;
387 2 my @m;
388 2 my $base = $self->[STRUCT][0];
389 2 my $cont = $self->[STRUCT][1];
390 2 for my $k (sort keys %$base) {
391 16 my $v;
392 16 ▶ if (@{$base->{$k}}>1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$base->{$k};} > 1) { } 4 12 16
393 4 $v = sprintf "%s (%s)", @{$base->{$k}};
394 } else {
395 12 $v = $base->{$k}[0];
396 }
397 16 push @m, sprintf "%-25s: %s", $k, $v;
398 }
399 2 for my $sr (@$cont) {
400 26 my $print = sprintf "%3s %1s %s [%s]", map { Dumpvalue::unctrl($_); } @$sr;
401 26 if (0 && $print =~ /[^\040-\177]/) {
402 $print .= sprintf("\n=%s\n=%s",
403 Encode::encode("ascii",$sr->[2],Encode::FB_XMLCREF()),
404 $sr->[2],
405 );
406 }
407 26 push @m, $print;
408 }
409 2 join "\n", @m;
410 }
411  
412 0 ▶sub dump {
Subroutine dump: not called CC=1 SCAR=6.9
Pod undocumented
413 0 my($self) = @_;
414 0 require Data::Dumper;
415 0 $Data::Dumper::Indent = 1;
416 0 $self->_struct;
417 0 my $x = Data::Dumper::Dumper($self);
418 0 $x =~ s/\[\n\s+/[/g;
419 0 $x =~ s/\n\s+\]/]/g;
420 0 $x =~ s/',\n\s+'/', '/g;
421 0 $x;
422 }
423  
424 2 ▶sub _class {
Subroutine _class: called CC=2 SCAR=7.0
425 2 my $self = shift;
426 2 my $type = substr($self->[RAW],23,1);
427 2 ▶ warn "ALERT: type[$type]" unless exists $type2pack{$type};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $MAB2::Record::Base::type2pack{$type} 0 2 2
428 2 $type2pack{$type};
429 }
430  
431 0 ▶sub id {
Subroutine id: not called CC=1 SCAR=6.9
Pod undocumented
432 0 my $self = shift;
433 0 my $id;
434 0 if (0) { # 228 secunden fuer Datei 12 (Keywords) ohne debug
435 # my $struct = $self->_struct;
436 # $id = $struct->[1][0][0] eq "001" ? $struct->[1][0][2] : die;
437 } else { # 67 secs fuer gleiche Arbeit, 852 secs fuer 01
438 0 my $raw = $self->as_string;
439 0 ($id) = substr($raw,28) =~ m/([^\c^\c]]+)/;
440 }
441 # warn "id[$id]";
442 # die Dumpvalue::unctrl("id1[$id1]id2[$id2]") unless $id1 eq $id2;
443 0 $id;
444 }
445  
446 2 ▶sub _struct {
Subroutine _struct: called CC=12 SCAR=25.5
447 2 my $self = shift;
448 2 ▶ return $self->[STRUCT] if $self->[STRUCT];
Branch: 1 branch
BranchTrueFalseTotal
if $self->[2] 0 2 2
449 2 my $struct;
450 2 ▶ if ($DEBUG) {
Branch: 1 branch
BranchTrueFalseTotal
if ($MAB2::Record::Base::DEBUG) 2 0 2
451 2 $self->[DUMPVALUE] = $DV->stringify($self->[RAW]);
452 }
453 2 my $derec = Encode::decode("MAB2",$self->[RAW]);
454 2 pos $derec = 0;
455 2 for my $k (@$KDocs) {
456 16 my $re = "."x$k->[2];
457 16 ▶ $struct->[0]{$k->[3]}[0] = $1 if $derec =~ /\G($re)/gc;
Branch: 1 branch
BranchTrueFalseTotal
if $derec =~ /\G($re)/cg 16 0 16
458 ##########^ 0=base/kennungsdocs
459 16 ▶ if ($DEBUG) {
Branch: 1 branch
BranchTrueFalseTotal
if ($MAB2::Record::Base::DEBUG) 16 0 16
460 16 ▶ $struct->[0]{$k->[3]}[1] = $k->[4]{$1} if %{$k->[4]};
Branch: 1 branch
BranchTrueFalseTotal
if %{$k->[4];} 4 12 16
461 }
462 }
463 warn "ALERT: Datenanfangsadresse nicht 24!" unless
464 2 ▶ (my $daa = $struct->[0]{datenanfangsadresse}[0]) == 24;
Branch: 1 branch
BranchTrueFalseTotal
unless (my $daa = $struct->[0]{"datenanfangsadresse"}[0]) == 24 0 2 2
465 # ^^^^^^^^^
466  
467 # avoid using stringdata in numeric context, because it turns on IOK
468 # or something and the next print prints "24" instead of "00024"
469  
470 # strp = structpart of the record
471 2 my(@strp) = $derec =~ / \G (\d\d\d) (.) ([^\c^]+) (?: \c] | \c^ )/xgc; #
472 2 my(@str);
473 2 ▶ while (@strp) {
Branch: 1 branch
BranchTrueFalseTotal
if (@strp) 26 2 28
474 26 ▶ die "Invalid strp" unless @strp >=3;
Branch: 1 branch
BranchTrueFalseTotal
unless @strp >= 3 0 26 26
475 26 my $str = [ splice @strp, 0, 3 ];
476 26 ▶ if ($DEBUG) {
Branch: 1 branch
BranchTrueFalseTotal
if ($MAB2::Record::Base::DEBUG) 26 0 26
477 # die Bezeichnung des Feldes im "real" Record. Da dort alles
478 # Uppercase ist, muessen wir lc nehmen, sonst erschlaegt uns das
479 26 ▶ $str->[3] = $str->[0] ? lc $self->segmentname($str->[0]) : "UNDEF";
Branch: 1 branch
BranchTrueFalseTotal
$str->[0] ? : 26 0 26
480 }
481 26 push @str, $str;
482 }
483 2 $struct->[1] = \@str;
484 2 $self->[STRUCT] = $struct;
485 }
486  
487 18 ▶sub segmentname {
Subroutine segmentname: called CC=1 SCAR=0.0
Pod undocumented
488 18 my $self = shift;
489 18 my $rec = shift;
490 18 $RDocs->{$rec}[3];
491 }
492  
493 0 ▶sub subrecords {
Subroutine subrecords: not called CC=1 SCAR=6.9
Pod undocumented
494 0 my($self) = shift;
495 0 $self->_struct;
496 0 @{$self->[STRUCT][1]};
497 }
498  
499 0 ▶sub subrecords_ref {
Subroutine subrecords_ref: not called CC=1 SCAR=6.9
Pod undocumented
500 0 my($self) = shift;
501 0 $self->_struct;
502 0 $self->[STRUCT][1];
503 }
504  
505 0 ▶sub date_004 {
Subroutine date_004: not called CC=3 SCAR=24.8
Pod undocumented
506 0 my($self) = @_;
507 0 my $sr = $self->subrecords_ref;
508 0 for my $i (0..$#$sr) {
509 0 ▶ next unless $sr->[$i][0] eq "004";
Branch: 1 branch
BranchTrueFalseTotal
unless $sr->[$i][0] eq "004" 0 0 0
510 0 return $sr->[$i][2];
511 }
512 }
513  
514 2 1;
515  
516 # segm000.txt
517 __DATA__
↑ Summary blib/lib/Encode/MAB2.pm »