/[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 335 by dpavlin, Wed Jun 2 16:13:57 2004 UTC revision 607 by dpavlin, Tue Dec 28 04:11:47 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    use Data::Dumper;
6    
7  my $file = shift @ARGV || die "Usage: $0 [marc file]";  my $file = shift @ARGV || die "Usage: $0 [marc file]";
8    
9  my $x = new MARC;  my $marc_file = MARC::File::USMARC->in($file) || die $MARC::File::ERROR;
 my $nr = $x->openmarc( { file => $file, format => 'usmarc' });  
10    
11  # read MARC file in memory  sub marc_count {
12  $x->nextmarc(-1);          my $filename = shift || die;
13            my $file = MARC::File::USMARC->in($filename) || die $MARC::File::ERROR;
14  my $max_rec = $x->marc_count();          my $count = 0;
15            while ($file->skip()) {
16                    $count++;
17            }
18            return $count;
19    }
20    
21  print "file '$file' with '",$x->marc_count(),"' records...\n";  print "file '$file' with ",marc_count($file)," records...\n";
22    
23  for(my $i=1; $i<=$max_rec; $i++) {  while( my $marc = $marc_file->next() ) {
24          print "REC #$i: ",$x->getfirstvalue({record=>$i,field=>245,subfield=>'a',delimiter=>" "}),"\n";          print "REC #",$marc->field('001')->as_string,": ",$marc->title,"\n";
25          print $x->output({format=>'ascii', record=>$i});          print $marc->as_formatted,"\n\n";
26  }  }
27    

Legend:
Removed from v.335  
changed lines
  Added in v.607

  ViewVC Help
Powered by ViewVC 1.1.26