#!/usr/bin/perl # xml2marc.pl - given a MARCXML file, output a plain o' MARC file # Eric Lease Morgan # March 29, 2016 - first cut # require use strict; use MARC::Batch; use warnings; # sanity check if ( ! $ARGV[ 0 ] ) { print "Usage: $0 \n"; exit; } # read and do the work my $batch = MARC::Batch->new( 'XML', $ARGV[ 0 ] ); # trap warnings; try to be as clean as possible if ( ! $batch->warnings ) { binmode STDOUT, ':utf8'; my $_001 = $ARGV[ 0 ]; $_001 =~ s/\D//g; my $record = $batch->next; $record->field( '001' )->update( $_001 ); eval { $record->as_usmarc }; if ( ! $^W) { print $record->as_usmarc; } } # done exit;