| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=head1 NAME |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Catmandu::Fix::Inline::marc_map - A marc_map-er for Perl scripts (DEPRECATED) |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Catmandu::Fix::Inline::marc_map qw(:all); |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $title = marc_map($data,'245a'); |
|
10
|
|
|
|
|
|
|
my @authors = marc_map($data,'100ab'); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Get all 245 in an array |
|
13
|
|
|
|
|
|
|
@arr = marc_map($data,'245'); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Or as a string |
|
16
|
|
|
|
|
|
|
$str = marc_map($data,'245'); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# str joined by a semi-colon |
|
19
|
|
|
|
|
|
|
$f245 = marc_map($data, '245', -join , ';'); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Get the 245-$a$b$c subfields ordered as given in the record |
|
22
|
|
|
|
|
|
|
$str = marc_map($data,'245abc'); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Get the 245-$c$b$a subfields orders as given in the mapping |
|
25
|
|
|
|
|
|
|
$str = marc_map($data,'245cba', -pluck => 1); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Get the 008 characters 35-35 |
|
28
|
|
|
|
|
|
|
$str = marc_map($data,'008_/35-35'); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Get all 100 subfields except the digits |
|
31
|
|
|
|
|
|
|
$str = marc_map($data,'100^0123456789'); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# If the 260c exist set the output to 'OK' (else undef) |
|
34
|
|
|
|
|
|
|
$ok = marc_map($data,'260c',-value => 'OK'); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# The $data should be a Catmandu-style MARC hash |
|
37
|
|
|
|
|
|
|
{ record => [ |
|
38
|
|
|
|
|
|
|
['field', 'ind1' , 'ind2' , 'subfieldcode or underscore' , 'data' , 'subfield' , 'data' , ...] , |
|
39
|
|
|
|
|
|
|
... |
|
40
|
|
|
|
|
|
|
]}; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Example |
|
43
|
|
|
|
|
|
|
$data = { record => [ |
|
44
|
|
|
|
|
|
|
['001' , ' ', ' ' , '_' , 'myrecord-001' ] , |
|
45
|
|
|
|
|
|
|
['020' , ' ', ' ' , 'a' , '978-1449303587' ] , |
|
46
|
|
|
|
|
|
|
['245' , ' ', ' ' , 'a' , 'Learning Per' , 'c', '/ by Randal L. Schwartz'], |
|
47
|
|
|
|
|
|
|
]}; |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 DEPRECATED |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
This module is deprecated. Use the inline functionality of L<Catmandu::Fix::marc_map> instead. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
L<Catmandu::Fix::Inline::marc_map> |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
package Catmandu::Fix::Inline::marc_map; |
|
60
|
|
|
|
|
|
|
|
|
61
|
3
|
|
|
3
|
|
273840
|
use Catmandu::MARC; |
|
|
3
|
|
|
|
|
16
|
|
|
|
3
|
|
|
|
|
762
|
|
|
62
|
|
|
|
|
|
|
require Exporter; |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
|
65
|
|
|
|
|
|
|
@EXPORT_OK = qw(marc_map); |
|
66
|
|
|
|
|
|
|
%EXPORT_TAGS = (all => [qw(marc_map)]); |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
our $VERSION = '1.19'; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub marc_map { |
|
71
|
30
|
|
|
30
|
0
|
46467
|
my ($data,$marc_path,%opts) = @_; |
|
72
|
|
|
|
|
|
|
# Set default to nested_arrays for backwards compatibility |
|
73
|
30
|
100
|
|
|
|
111
|
$opts{'-join'} = '' unless exists $opts{'-join'}; |
|
74
|
30
|
100
|
|
|
|
72
|
$opts{'-split'} = 0 unless exists $opts{'-split'}; |
|
75
|
30
|
100
|
|
|
|
65
|
$opts{'-pluck'} = 0 unless exists $opts{'-pluck'}; |
|
76
|
30
|
100
|
|
|
|
70
|
$opts{'-nested_arrays'} = 1 unless exists $opts{'-nested_arrays'}; |
|
77
|
|
|
|
|
|
|
|
|
78
|
30
|
100
|
|
|
|
61
|
$opts{'-force_array'} = 1 if (wantarray); |
|
79
|
|
|
|
|
|
|
|
|
80
|
30
|
|
|
|
|
101
|
my $vals = Catmandu::MARC->instance->marc_map( |
|
81
|
|
|
|
|
|
|
$data, |
|
82
|
|
|
|
|
|
|
$marc_path, |
|
83
|
|
|
|
|
|
|
\%opts); |
|
84
|
|
|
|
|
|
|
|
|
85
|
30
|
100
|
|
|
|
81
|
$vals = $vals->[0] if $opts{'-split'}; |
|
86
|
|
|
|
|
|
|
|
|
87
|
30
|
100
|
|
|
|
88
|
if (wantarray) { |
|
88
|
7
|
50
|
33
|
|
|
46
|
defined($vals) && ref($vals) eq 'ARRAY' ? @$vals : ($vals); |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
else { |
|
91
|
23
|
|
|
|
|
104
|
$vals; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |