line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::marc_set; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
874
|
use Catmandu::Sane; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
10
|
|
4
|
2
|
|
|
2
|
|
324
|
use Moo; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
12
|
|
5
|
2
|
|
|
2
|
|
896
|
use Catmandu::MARC; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
50
|
|
6
|
2
|
|
|
2
|
|
319
|
use Catmandu::Fix::Has; |
|
2
|
|
|
|
|
790
|
|
|
2
|
|
|
|
|
11
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
with 'Catmandu::Fix::Inlineable'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.21'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has marc_path => (fix_arg => 1); |
13
|
|
|
|
|
|
|
has value => (fix_arg => 1); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub fix { |
16
|
6
|
|
|
6
|
0
|
6576
|
my ($self,$data) = @_; |
17
|
6
|
|
|
|
|
29
|
my $marc_path = $self->marc_path; |
18
|
6
|
|
|
|
|
18
|
my $value = $self->value; |
19
|
6
|
|
|
|
|
30
|
return Catmandu::MARC->instance->marc_set($data,$marc_path,$value); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 NAME |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Catmandu::Fix::marc_set - set a marc value of one (sub)field to a new value |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 SYNOPSIS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Set a field in the leader |
29
|
|
|
|
|
|
|
if marc_match('LDR/6','c') |
30
|
|
|
|
|
|
|
marc_set('LDR/6','p') |
31
|
|
|
|
|
|
|
end |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Set a control field |
34
|
|
|
|
|
|
|
marc_set('001',1234) |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Set all the 650-p fields to 'test' |
37
|
|
|
|
|
|
|
marc_set('650p','test') |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Set the 100-a subfield where indicator-1 is 3 |
40
|
|
|
|
|
|
|
marc_set('100[3]a','Farquhar family.') |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Copy data from another field in a subfield |
43
|
|
|
|
|
|
|
marc_set('100a','$.my.deep.field') |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 DESCRIPTION |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Set the value of a MARC subfield to a new value. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 METHODS |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 marc_set(MARC_PATH , VALUE) |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Set a MARC subfield to a particular new value. This value can be a literal or |
54
|
|
|
|
|
|
|
reference an existing field in the record using the dollar JSON_PATH syntax. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 INLINE |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This Fix can be used inline in a Perl script: |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
use Catmandu::Fix::marc_set as => 'marc_set'; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
my $data = { record => [...] }; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
$data = marc_set($data, '245a', 'test'); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 SEE ALSO |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
L<Catmandu::Fix::marc_add>, |
69
|
|
|
|
|
|
|
L<Catmandu::Fix::marc_copy>, |
70
|
|
|
|
|
|
|
L<Catmandu::Fix::marc_cut>, |
71
|
|
|
|
|
|
|
L<Catmandu::Fix::marc_paste> |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |