#!/usr/local/bin/perl -w # I had a MARC file with a bunch of records that were causing problems, # so I wrote this to wipe out anything possibly troublesome. This is # not, in general, how you should handle MARC records. my $oldmarc = shift; my $newmarc = "clean-" . $oldmarc; die "Usage: $0 old.marc\n" unless defined $oldmarc; unlink $newmarc if -e $newmarc; use MARC; use MARC::Lint; use Data::Dumper; my $m = MARC->new($oldmarc); my @records_to_drop = qw (424082 377949 ocn185998486x UkOxUb13452708 UkOxUb10549368 002868810 UkOxUb13394216 UkOxUb10869435 ocm33018749 000028642527 2576631 UkOxUb11404428 UkOxUb10631963 UkOxUb10780861 UkOxUb10765910 ocm61728325 13785458 13610296 13598586 13463288 13477810 13097425 13097424 5338018 3523264 ); foreach my $record (sort @records_to_drop) { print "Removing record $record ...\n"; @delete = $m->searchmarc({field => "001", regex => "/$record/"}); $m->deletemarc({record => @delete}); } my @fields_to_remove = qw(200 280 380 400 450 500 520 600 840 240); foreach my $field (@fields_to_remove) { print "Removing $field ...\n"; $m->deletemarc({field => $field}); } $m->output({'file' => ">$newmarc", 'format' => 'usmarc'});