#!/usr/bin/perl -w
use strict;
-use MARC;
+use MARC::File::USMARC;
+use Data::Dumper;
my $file = shift @ARGV || die "Usage: $0 [marc file]";
-my $x = new MARC;
-my $nr = $x->openmarc( { file => $file, format => 'usmarc' });
+my $marc_file = MARC::File::USMARC->in($file) || die $MARC::File::ERROR;
-print "file '$file' with '",$x->marc_count(),"' records...\n";
+sub marc_count {
+ my $filename = shift || die;
+ my $file = MARC::File::USMARC->in($filename) || die $MARC::File::ERROR;
+ my $count = 0;
+ while ($file->skip()) {
+ $count++;
+ }
+ return $count;
+}
-while ($x->nextmarc(1)) {
- print $x->output({format=>'ascii'}); # FIX
+print "file '$file' with ",marc_count($file)," records...\n";
- my $rec = $x->marc_count();
- print $x->getfirstvalue({record=>$rec,field=>245,subfield=>'a',delimiter=>" "}),"<--\n";
+while( my $marc = $marc_file->next() ) {
+ print "REC #",$marc->field('001')->as_string,": ",$marc->title,"\n";
+ print $marc->as_formatted,"\n\n";
}