| 1 | package Catmandu::Fix::marc_set; | ||
| 2 | |||
| 3 | 2 | ▶ | use Catmandu::Sane; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 2 | ▶ | use Catmandu::MARC; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 2 | ▶ | use Catmandu::Fix::Has; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 2 | with 'Catmandu::Fix::Inlineable'; | |
| 9 | |||
| 10 | 2 | our $VERSION = '1.33'; | |
| 11 | |||
| 12 | 2 | has marc_path => (fix_arg => 1); | |
| 13 | 2 | has value => (fix_arg => 1); | |
| 14 | |||
| 15 | 6 | ▶ | sub fix { |
|
Subroutine
fix: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 16 | 6 | my ($self,$data) = @_; | |
| 17 | 6 | my $marc_path = $self->marc_path; | |
| 18 | 6 | my $value = $self->value; | |
| 19 | 6 | 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 | 2 | 1; | |