/[webpac]/branches/drustvene/tools/dump_marc.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /branches/drustvene/tools/dump_marc.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 602 by dpavlin, Wed Jun 2 16:13:57 2004 UTC revision 603 by dpavlin, Mon Dec 27 21:00:20 2004 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl -w  #!/usr/bin/perl -w
2    
3  use strict;  use strict;
4  use MARC;  use MARC::File::USMARC;
5    
6  my $file = shift @ARGV || die "Usage: $0 [marc file]";  my $file = shift @ARGV || die "Usage: $0 [marc file]";
7    
8  my $x = new MARC;  my $marc_file = MARC::File::USMARC->in($file) || die $MARC::File::ERROR;
 my $nr = $x->openmarc( { file => $file, format => 'usmarc' });  
9    
10  # read MARC file in memory  sub marc_count {
11  $x->nextmarc(-1);          my $filename = shift || die;
12            my $file = MARC::File::USMARC->in($filename) || die $MARC::File::ERROR;
13  my $max_rec = $x->marc_count();          my $count = 0;
14            while ($file->skip()) {
15                    $count++;
16            }
17            return $count;
18    }
19    
20  print "file '$file' with '",$x->marc_count(),"' records...\n";  print "file '$file' with ",marc_count($file)," records...\n";
21    
22  for(my $i=1; $i<=$max_rec; $i++) {  my $i = 1;
23          print "REC #$i: ",$x->getfirstvalue({record=>$i,field=>245,subfield=>'a',delimiter=>" "}),"\n";  while( my $marc = $marc_file->next() ) {
24          print $x->output({format=>'ascii', record=>$i});          print "REC #",$i++,": ",$marc->title,"\n";
25            print $marc->as_formatted,"\n\n";
26  }  }
27    

Legend:
Removed from v.602  
changed lines
  Added in v.603

  ViewVC Help
Powered by ViewVC 1.1.26