#!/usr/bin/perl -w

use strict;
use MARC::File::USMARC;
use Data::Dumper;

my $file = shift @ARGV || die "Usage: $0 [marc file]";

my $marc_file = MARC::File::USMARC->in($file) || die $MARC::File::ERROR;

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;
}

print "file '$file' with ",marc_count($file)," records...\n";

while( my $marc = $marc_file->next() ) {
	print "REC #",$marc->field('001')->as_string,": ",$marc->title,"\n";
	print $marc->as_formatted,"\n\n";
}

