| Revision 209 (by dpavlin, 2004/02/01 20:35:59) |
I was using MARC.pm wrong. It duplicated records in output
|
#!/usr/bin/perl -w
use strict;
use MARC;
my $file = shift @ARGV || die "Usage: $0 [marc file]";
my $x = new MARC;
my $nr = $x->openmarc( { file => $file, format => 'usmarc' });
# read MARC file in memory
$x->nextmarc(-1);
my $max_rec = $x->marc_count();
print "file '$file' with '",$x->marc_count(),"' records...\n";
for(my $i=1; $i<=$max_rec; $i++) {
print "REC #$i: ",$x->getfirstvalue({record=>$i,field=>245,subfield=>'a',delimiter=>" "}),"\n";
print $x->output({format=>'ascii', record=>$i});
}