/usr/share/perl5/Catmandu/Fix/marc_add.pm is in libcatmandu-marc-perl 0.206-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | package Catmandu::Fix::marc_add;
use Catmandu::Sane;
use Moo;
use Catmandu::Fix::Has;
has marc_tag => (fix_arg => 1);
has subfields => (fix_arg => 'collect');
sub fix {
my ($self, $data) = @_;
my $marc_tag = $self->marc_tag;
my @subfields = @{$self->subfields};
my %subfields = @subfields;
my $record_key = $subfields{'-record'} // 'record';
my $marc = $data->{$record_key} // [];
if ($marc_tag =~ /^\w{3}$/) {
my @field = ();
push @field , $marc_tag;
push @field , $subfields{ind1} // ' ';
push @field , $subfields{ind2} // ' ';
for (my $i = 0 ; $i < @subfields ; $i += 2) {
my $code = $subfields[$i];
next unless length $code == 1;
my $value = $subfields[$i+1];
push @field , $code;
push @field , $value;
}
push @{ $marc } , \@field;
$data->{$record_key} = $marc;
}
$data;
}
=head1 NAME
Catmandu::Fix::marc_add - add new fields to marc
=head1 SYNOPSIS
marc_add('900', a, 'test' , 'b', test)
marc_add('900', ind1 , ' ' , a, 'test' , 'b', test)
marc_add('900', ind1 , ' ' , a, 'test' , 'b', test , -record => 'record2')
=head1 DESCRIPTION
Read our Wiki pages at L<https://github.com/LibreCat/Catmandu/wiki/Fixes> for a complete
overview of the Fix language.
=head1 SEE ALSO
L<Catmandu::Fix>
=cut
1;
|