added option -n number to dump just one record and -d for debug
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 8 Oct 2005 16:32:54 +0000 (16:32 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 8 Oct 2005 16:32:54 +0000 (16:32 +0000)
git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/MARC-Fast/trunk@4 49f9634a-d7ec-0310-8e6b-ec35c6cc8804

scripts/dump_fastmarc.pl

index 1257ac3..a37171c 100755 (executable)
@@ -4,20 +4,31 @@ use strict;
 use blib;
 
 use MARC::Fast;
-
+use Getopt::Std;
 use Data::Dumper;
 
-my $file = shift @ARGV || die "usage: $0 file.marc\n";
-my $debug = shift @ARGV;
+my %opt;
+getopts('dn:', \%opt);
+
+my $file = shift @ARGV || die "usage: $0 [-n number] [-d] file.marc\n";
 
 my $marc = new MARC::Fast(
        marcdb => $file,
-       debug => $debug,
+       debug => $opt{'d'},
 );
 
-print STDERR "$file has ",$marc->count," records...\n\n";
+print STDERR "$file has ",$marc->count," records...\n";
+
+my $min = 1;
+my $max = $marc->count;
+
+if (my $mfn = $opt{'n'}) {
+       $min = $max = $mfn;
+}
+
+print STDERR "Dumping $min - $max\n" if ($opt{'d'});
 
-for my $mfn (1 .. $marc->count) {
+for my $mfn ($min .. $max) {
        my $rec = $marc->fetch($mfn) || next;
        print "REC $mfn\n";
        foreach my $f (sort keys %{$rec}) {