36 |
|
|
37 |
=head1 VERSION |
=head1 VERSION |
38 |
|
|
39 |
Version 0.15 |
Version 0.16 |
40 |
|
|
41 |
=cut |
=cut |
42 |
|
|
43 |
our $VERSION = '0.15'; |
our $VERSION = '0.16'; |
44 |
|
|
45 |
=head1 SYNOPSIS |
=head1 SYNOPSIS |
46 |
|
|
646 |
|
|
647 |
Copy all subfields preserving original order to marc field. |
Copy all subfields preserving original order to marc field. |
648 |
|
|
649 |
marc_original_order(210, 260); |
marc_original_order( marc_field_number, original_input_field_number ); |
650 |
|
|
651 |
|
Please note that field numbers are consistent with other commands (marc |
652 |
|
field number first), but somewhat counter-intuitive (destination and then |
653 |
|
source). |
654 |
|
|
655 |
You might want to use this command if you are just renaming subfields or |
You might want to use this command if you are just renaming subfields or |
656 |
using pre-processing modify_record in C<config.yml> and don't need any |
using pre-processing modify_record in C<config.yml> and don't need any |
657 |
post-processing or want to preserve order of original subfields. |
post-processing or want to preserve order of original subfields. |
658 |
|
|
659 |
|
|
660 |
=cut |
=cut |
661 |
|
|
662 |
sub marc_original_order { |
sub marc_original_order { |
663 |
|
|
664 |
my ($from, $to) = @_; |
my ($to, $from) = @_; |
665 |
die "marc_original_order needs from and to fields\n" unless ($from && $to); |
die "marc_original_order needs from and to fields\n" unless ($from && $to); |
666 |
|
|
667 |
my $r = $rec->{$from} || return; |
return unless defined($rec->{$from}); |
668 |
|
|
669 |
|
my $r = $rec->{$from}; |
670 |
die "record field $from isn't array\n" unless (ref($r) eq 'ARRAY'); |
die "record field $from isn't array\n" unless (ref($r) eq 'ARRAY'); |
671 |
|
|
672 |
my ($i1,$i2) = defined($marc_indicators->{$to}) ? @{ $marc_indicators->{$to} } : (' ',' '); |
my ($i1,$i2) = defined($marc_indicators->{$to}) ? @{ $marc_indicators->{$to} } : (' ',' '); |
673 |
warn "## marc_original_order($from,$to) source = ", dump( $r ),$/ if ($debug > 1); |
warn "## marc_original_order($to,$from) source = ", dump( $r ),$/ if ($debug > 1); |
674 |
|
|
675 |
foreach my $d (@$r) { |
foreach my $d (@$r) { |
676 |
|
|
677 |
if (! defined($d->{subfields}) && ref($d->{subfields}) ne 'ARRAY') { |
if (! defined($d->{subfields}) && ref($d->{subfields}) ne 'ARRAY') { |
678 |
warn "# marc_original_order($from,$to): field $from doesn't have subfields specification\n"; |
warn "# marc_original_order($to,$from): field $from doesn't have subfields specification\n"; |
679 |
next; |
next; |
680 |
} |
} |
681 |
|
|