From: Dobrica Pavlinusic Date: Sat, 8 Oct 2005 16:32:54 +0000 (+0000) Subject: added option -n number to dump just one record and -d for debug X-Git-Url: http://git.rot13.org/?p=MARC-Fast;a=commitdiff_plain;h=bf7a8cd995686ae3652408d5c58067aba565bf2a added option -n number to dump just one record and -d for debug git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/MARC-Fast/trunk@4 49f9634a-d7ec-0310-8e6b-ec35c6cc8804 --- diff --git a/scripts/dump_fastmarc.pl b/scripts/dump_fastmarc.pl index 1257ac3..a37171c 100755 --- a/scripts/dump_fastmarc.pl +++ b/scripts/dump_fastmarc.pl @@ -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}) {