line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MARC::Record::Generic; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: read/write MARC data into Perl primitives |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
28946
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
6
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
32
|
|
7
|
1
|
|
|
1
|
|
960
|
use MARC::Record; |
|
1
|
|
|
|
|
10260
|
|
|
1
|
|
|
|
|
58
|
|
8
|
1
|
|
|
1
|
|
12
|
use MARC::Field; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
295
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = 0.001; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# MARC::Record -> generic hash |
13
|
|
|
|
|
|
|
sub MARC::Record::as_generic { |
14
|
1
|
|
|
1
|
0
|
1084
|
my $self = shift; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
return { |
17
|
42
|
|
|
|
|
1040
|
leader => $self->leader, |
18
|
|
|
|
|
|
|
fields => [ map { |
19
|
1
|
|
|
|
|
7
|
$_->tag, |
20
|
|
|
|
|
|
|
( $_->is_control_field |
21
|
|
|
|
|
|
|
? $_->data |
22
|
|
|
|
|
|
|
: { |
23
|
|
|
|
|
|
|
ind1 => $_->indicator(1), |
24
|
|
|
|
|
|
|
ind2 => $_->indicator(2), |
25
|
27
|
100
|
|
|
|
139
|
subfields => [ map { ($_->[0], $_->[1]) } $_->subfields ], |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
) |
28
|
|
|
|
|
|
|
} $self->fields ], |
29
|
|
|
|
|
|
|
}; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# generic hash -> MARC::Record |
33
|
|
|
|
|
|
|
sub MARC::Record::new_from_generic { |
34
|
2
|
|
|
2
|
0
|
93
|
my ($class, $data) = @_; |
35
|
2
|
|
|
|
|
10
|
my $record = MARC::Record->new(); |
36
|
2
|
|
|
|
|
25
|
$record->leader( $data->{leader} ); |
37
|
|
|
|
|
|
|
|
38
|
2
|
|
|
|
|
20
|
my @fields; |
39
|
2
|
|
|
|
|
2
|
@_ = @{$data->{fields}}; |
|
2
|
|
|
|
|
35
|
|
40
|
2
|
|
|
|
|
11
|
while ( @_ ) { |
41
|
54
|
|
|
|
|
2054
|
my ($tag, $val) = (shift, shift); |
42
|
|
|
|
|
|
|
my @attrs |
43
|
48
|
|
|
|
|
107
|
= ref($val) eq 'HASH' |
44
|
54
|
100
|
|
|
|
131
|
? ( $val->{ind1}, $val->{ind2}, @{$val->{subfields}} ) |
45
|
|
|
|
|
|
|
: ( $val ); |
46
|
54
|
|
|
|
|
140
|
push @fields, MARC::Field->new( $tag, @attrs ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
2
|
|
|
|
|
71
|
$record->append_fields( @fields ); |
50
|
2
|
|
|
|
|
102
|
return $record; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |