use IsisDB module instead of OpenIsis -- this will fix various problems in
[webpac] / tools / dump_marc.pl
1 #!/usr/bin/perl -w
2
3 use strict;
4 use MARC::File::USMARC;
5 use Data::Dumper;
6
7 my $file = shift @ARGV || die "Usage: $0 [marc file]";
8
9 my $marc_file = MARC::File::USMARC->in($file) || die $MARC::File::ERROR;
10
11 sub marc_count {
12         my $filename = shift || die;
13         my $file = MARC::File::USMARC->in($filename) || die $MARC::File::ERROR;
14         my $count = 0;
15         while ($file->skip()) {
16                 $count++;
17         }
18         return $count;
19 }
20
21 print "file '$file' with ",marc_count($file)," records...\n";
22
23 while( my $marc = $marc_file->next() ) {
24         print "REC #",$marc->field('001')->as_string,": ",$marc->title,"\n";
25         print $marc->as_formatted,"\n\n";
26 }
27