41 |
|
|
42 |
=head1 VERSION |
=head1 VERSION |
43 |
|
|
44 |
Version 0.24 |
Version 0.25 |
45 |
|
|
46 |
=cut |
=cut |
47 |
|
|
48 |
our $VERSION = '0.24'; |
our $VERSION = '0.25'; |
49 |
|
|
50 |
=head1 SYNOPSIS |
=head1 SYNOPSIS |
51 |
|
|
637 |
|
|
638 |
This will erase field C<200> or C<200^a> from current MARC record. |
This will erase field C<200> or C<200^a> from current MARC record. |
639 |
|
|
640 |
|
marc_remove('*'); |
641 |
|
|
642 |
|
Will remove all fields in current MARC record. |
643 |
|
|
644 |
This is useful after calling C<marc_duplicate> or on it's own (but, you |
This is useful after calling C<marc_duplicate> or on it's own (but, you |
645 |
should probably just remove that subfield definition if you are not |
should probably just remove that subfield definition if you are not |
646 |
using C<marc_duplicate>). |
using C<marc_duplicate>). |
658 |
|
|
659 |
warn "### marc_remove before = ", dump( $marc ), $/ if ($debug > 2); |
warn "### marc_remove before = ", dump( $marc ), $/ if ($debug > 2); |
660 |
|
|
661 |
my $i = 0; |
if ($f eq '*') { |
662 |
foreach ( 0 .. $#{ $marc } ) { |
|
663 |
last unless (defined $marc->[$i]); |
delete( $marc_record->[ $marc_record_offset ] ); |
664 |
warn "#### working on ",dump( @{ $marc->[$i] }), $/ if ($debug > 3); |
|
665 |
if ($marc->[$i]->[0] eq $f) { |
} else { |
666 |
if (! defined $sf) { |
|
667 |
# remove whole field |
my $i = 0; |
668 |
splice @$marc, $i, 1; |
foreach ( 0 .. $#{ $marc } ) { |
669 |
warn "#### slice \@\$marc, $i, 1 = ",dump( @{ $marc }), $/ if ($debug > 3); |
last unless (defined $marc->[$i]); |
670 |
$i--; |
warn "#### working on ",dump( @{ $marc->[$i] }), $/ if ($debug > 3); |
671 |
} else { |
if ($marc->[$i]->[0] eq $f) { |
672 |
foreach my $j ( 0 .. (( $#{ $marc->[$i] } - 3 ) / 2) ) { |
if (! defined $sf) { |
673 |
my $o = ($j * 2) + 3; |
# remove whole field |
674 |
if ($marc->[$i]->[$o] eq $sf) { |
splice @$marc, $i, 1; |
675 |
# remove subfield |
warn "#### slice \@\$marc, $i, 1 = ",dump( @{ $marc }), $/ if ($debug > 3); |
676 |
splice @{$marc->[$i]}, $o, 2; |
$i--; |
677 |
warn "#### slice \@{\$marc->[$i]}, $o, 2 = ", dump( @{ $marc }), $/ if ($debug > 3); |
} else { |
678 |
# is record now empty? |
foreach my $j ( 0 .. (( $#{ $marc->[$i] } - 3 ) / 2) ) { |
679 |
if ($#{ $marc->[$i] } == 2) { |
my $o = ($j * 2) + 3; |
680 |
splice @$marc, $i, 1; |
if ($marc->[$i]->[$o] eq $sf) { |
681 |
warn "#### slice \@\$marc, $i, 1 = ", dump( @{ $marc }), $/ if ($debug > 3); |
# remove subfield |
682 |
$i--; |
splice @{$marc->[$i]}, $o, 2; |
683 |
}; |
warn "#### slice \@{\$marc->[$i]}, $o, 2 = ", dump( @{ $marc }), $/ if ($debug > 3); |
684 |
|
# is record now empty? |
685 |
|
if ($#{ $marc->[$i] } == 2) { |
686 |
|
splice @$marc, $i, 1; |
687 |
|
warn "#### slice \@\$marc, $i, 1 = ", dump( @{ $marc }), $/ if ($debug > 3); |
688 |
|
$i--; |
689 |
|
}; |
690 |
|
} |
691 |
} |
} |
692 |
} |
} |
693 |
} |
} |
694 |
|
$i++; |
695 |
} |
} |
|
$i++; |
|
|
} |
|
696 |
|
|
697 |
warn "### marc_remove($f", $sf ? ",$sf" : "", ") after = ", dump( $marc ), $/ if ($debug > 2); |
warn "### marc_remove($f", $sf ? ",$sf" : "", ") after = ", dump( $marc ), $/ if ($debug > 2); |
698 |
|
|
699 |
|
$marc_record->[ $marc_record_offset ] = $marc; |
700 |
|
} |
701 |
|
|
|
$marc_record->[ $marc_record_offset ] = $marc; |
|
702 |
|
|
703 |
warn "## full marc_record = ", dump( @{ $marc_record }), $/ if ($debug > 1); |
warn "## full marc_record = ", dump( @{ $marc_record }), $/ if ($debug > 1); |
704 |
} |
} |