X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=blobdiff_plain;f=munge_001_003_035.pl;h=46e23528955fa342a61e40fff09bb133eda90d57;hp=8dceb7d6777acbd6d59f7d1594a1ae01290541fe;hb=HEAD;hpb=2cbcec09ac6b22982fd5abfe08cc79f7209710af diff --git a/munge_001_003_035.pl b/munge_001_003_035.pl old mode 100644 new mode 100755 index 8dceb7d..46e2352 --- a/munge_001_003_035.pl +++ b/munge_001_003_035.pl @@ -6,11 +6,17 @@ use MARC::File::USMARC; my $file = MARC::File::USMARC->in( $ARGV[0] ); while ( my $marc = $file->next() ) { my @cns = $marc->field('001'); # grabs all of them - my $cn = $marc->field('001')->data(); # grabs the first - $marc->delete_fields(@cns); # deletes all of them + my $cn; + if (@cns) { + $cn = $marc->field('001')->data(); # grabs the first + $marc->delete_fields(@cns); # deletes all of them + } my @sources = $marc->field('003'); # etc - my $source = $marc->field('003')->data(); - $marc->delete_fields(@sources); + my $source; + if (@sources) { + $source = $marc->field('003')->data(); + $marc->delete_fields(@sources); + } my @tags035 = $marc->field('035'); my $tag035 = $marc->field('035'); my $tag035a = defined $tag035 ? $tag035->subfield('a') : undef; @@ -36,4 +42,3 @@ while ( my $marc = $file->next() ) { } $file->close(); undef $file; -