--- trunk/scripts/dump_fastmarc.pl 2005/04/08 12:19:24 3 +++ trunk/scripts/dump_fastmarc.pl 2005/10/08 16:32:54 4 @@ -4,20 +4,31 @@ 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}) {