#!/usr/bin/perl -w
use strict;
+use warnings;
+
+use Error qw/:try/;
use Getopt::Long;
use MARC::File::XML( BinaryEncoding => 'utf8', RecordFormat => 'USMARC' );
+use MARC::Batch;
# Clean up URIs from MARCXML records prior to batch ingest
# * If we detect a proxy URL:
exit();
}
-my $input = MARC::File::XML->in( $input_file );
+my $input = new MARC::Batch( 'XML', $input_file );
+$input->strict_off();
my $output = MARC::File::XML->out( $output_file );
my ($touched, $url_cnt, $ind1_cnt, $ind2_cnt, $sub9_cnt) = (0, 0, 0, 0, 0);
-while (my $marc = $input->next()) {
+my $marc;
+while ( try { $marc = $input->next() } otherwise { $marc = -1 } ) {
+ # Skip the record if we couldn't even decode it
+ next if ($marc == -1);
+
my $edited = 0;
my @uri_fields = $marc->field('856');
foreach my $uri (@uri_fields) {