line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MAB2::Writer::Disk; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.24'; |
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
101854
|
use strict; |
|
3
|
|
|
|
|
18
|
|
|
3
|
|
|
|
|
100
|
|
6
|
3
|
|
|
3
|
|
1106
|
use charnames ':full'; |
|
3
|
|
|
|
|
63560
|
|
|
3
|
|
|
|
|
36
|
|
7
|
3
|
|
|
3
|
|
1676
|
use Readonly; |
|
3
|
|
|
|
|
6417
|
|
|
3
|
|
|
|
|
168
|
|
8
|
3
|
|
|
3
|
|
549
|
use Moo; |
|
3
|
|
|
|
|
11309
|
|
|
3
|
|
|
|
|
27
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with 'MAB2::Writer::Handle'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has subfield_indicator => ( |
13
|
|
|
|
|
|
|
is => 'rw', |
14
|
|
|
|
|
|
|
default => sub { qq{\N{INFORMATION SEPARATOR ONE}} } |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Readonly my $END_OF_FIELD => qq{\N{LINE FEED}}; |
19
|
|
|
|
|
|
|
Readonly my $END_OF_RECORD => qq{\N{LINE FEED}}; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub _write_record { |
23
|
6
|
|
|
6
|
|
13
|
my ( $self, $record ) = @_; |
24
|
6
|
|
|
|
|
112
|
my $fh = $self->fh; |
25
|
6
|
|
|
|
|
72
|
my $SUBFIELD_INDICATOR = $self->subfield_indicator; |
26
|
|
|
|
|
|
|
|
27
|
6
|
100
|
|
|
|
20
|
if ( $record->[0][0] eq 'LDR' ) { |
28
|
2
|
|
|
|
|
4
|
my $leader = $record->[0]; |
29
|
2
|
|
|
|
|
9
|
print $fh "### ", $leader->[3], $END_OF_FIELD; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
else { |
32
|
|
|
|
|
|
|
# set default record leader |
33
|
4
|
|
|
|
|
58
|
print $fh "### 99999nM2.01200024 h", $END_OF_FIELD; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
6
|
|
|
|
|
46
|
foreach my $field (@$record) { |
37
|
14
|
100
|
|
|
|
55
|
next if $field->[0] eq 'LDR'; |
38
|
12
|
100
|
|
|
|
26
|
if ( $field->[2] eq '_' ) { |
39
|
6
|
|
|
|
|
23
|
print $fh $field->[0], $field->[1], $field->[3], $END_OF_FIELD; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
else { |
42
|
6
|
|
|
|
|
20
|
print $fh $field->[0], $field->[1]; |
43
|
6
|
|
|
|
|
32
|
for ( my $i = 2; $i < scalar @$field; $i += 2 ) { |
44
|
9
|
|
|
|
|
14
|
my $subfield_code = $field->[ $i ]; |
45
|
9
|
|
|
|
|
16
|
my $value = $field->[ $i + 1 ]; |
46
|
9
|
|
|
|
|
24
|
print $fh $SUBFIELD_INDICATOR, $subfield_code, $value; |
47
|
|
|
|
|
|
|
} |
48
|
6
|
|
|
|
|
14
|
print $fh $END_OF_FIELD; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
6
|
|
|
|
|
38
|
print $fh $END_OF_RECORD; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=pod |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=encoding UTF-8 |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 NAME |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
MAB2::Writer::Disk - MAB2 Diskette format serializer |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 SYNOPSIS |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
L<MAB2::Writer::Disk> is a MAB2 Diskette serializer. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
use MAB2::Writer::Disk; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my @mab_records = ( |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
[ |
76
|
|
|
|
|
|
|
['001', ' ', '_', '2415107-5'], |
77
|
|
|
|
|
|
|
['331', ' ', '_', 'Code4Lib journal'], |
78
|
|
|
|
|
|
|
['655', 'e', 'u', 'http://journal.code4lib.org/', 'z', 'kostenfrei'], |
79
|
|
|
|
|
|
|
... |
80
|
|
|
|
|
|
|
], |
81
|
|
|
|
|
|
|
{ |
82
|
|
|
|
|
|
|
record => [ |
83
|
|
|
|
|
|
|
['001', ' ', '_', '2415107-5'], |
84
|
|
|
|
|
|
|
['331', ' ', '_', 'Code4Lib journal'], |
85
|
|
|
|
|
|
|
['655', 'e', 'u', 'http://journal.code4lib.org/', 'z', 'kostenfrei'], |
86
|
|
|
|
|
|
|
... |
87
|
|
|
|
|
|
|
] |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
$writer = MAB2::Writer::Disk->new( fh => $fh ); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
foreach my $record (@mab_records) { |
94
|
|
|
|
|
|
|
$writer->write($record); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 Arguments |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=over |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item C<subfield_indicator> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Set subfield separator. Default: INFORMATION SEPARATOR ONE. Optional. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=back |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
See also L<MAB2::Writer::Handle>. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 METHODS |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 new(file => $file | fh => $fh [, encoding => 'UTF-8', subfield_separator => '$']) |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 _write_record($record) |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 SEEALSO |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
L<MAB2::Writer::Handle>, L<Catmandu::Exporter>. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 AUTHOR |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Johann Rolschewski <jorol@cpan.org> |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
This software is copyright (c) 2013 by Johann Rolschewski. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
128
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |