line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::marc_set; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
855
|
use Catmandu::Sane; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
11
|
|
4
|
2
|
|
|
2
|
|
328
|
use Moo; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
16
|
|
5
|
2
|
|
|
2
|
|
882
|
use Catmandu::MARC; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
44
|
|
6
|
2
|
|
|
2
|
|
269
|
use Catmandu::Fix::Has; |
|
2
|
|
|
|
|
727
|
|
|
2
|
|
|
|
|
10
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
with 'Catmandu::Fix::Inlineable'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.19'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has marc_path => (fix_arg => 1); |
13
|
|
|
|
|
|
|
has value => (fix_arg => 1); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub fix { |
16
|
6
|
|
|
6
|
0
|
8867
|
my ($self,$data) = @_; |
17
|
6
|
|
|
|
|
28
|
my $marc_path = $self->marc_path; |
18
|
6
|
|
|
|
|
20
|
my $value = $self->value; |
19
|
6
|
|
|
|
|
40
|
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; |