From: Dobrica Pavlinusic Date: Wed, 28 Dec 2005 22:03:24 +0000 (+0000) Subject: pod documentation, new options, much nicer output X-Git-Url: http://git.rot13.org/?p=MARC-Fast;a=commitdiff_plain;h=1eb9ffc53258d90a524ef05e88d9321c042def92 pod documentation, new options, much nicer output git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/MARC-Fast/trunk@7 49f9634a-d7ec-0310-8e6b-ec35c6cc8804 --- diff --git a/scripts/dump_fastmarc.pl b/scripts/dump_fastmarc.pl index 538f8ea..eb0fd0c 100755 --- a/scripts/dump_fastmarc.pl +++ b/scripts/dump_fastmarc.pl @@ -7,34 +7,72 @@ use MARC::Fast; use Getopt::Std; use Data::Dumper; +=head1 NAME + +dump_fastmarc.pl - display MARC records + +=head2 USAGE + + dump_fastmarc.pl /path/to/dump.marc + +=head2 OPTIONS + +=over 16 + +=item -n number + +dump just record C + +=item -l limit + +import just first C records + +=item -h + +dump result of C on record + +=item -d + +turn debugging output on + +=back + +=cut + my %opt; -getopts('dn:', \%opt); +getopts('dn:l:h', \%opt); -my $file = shift @ARGV || die "usage: $0 [-n number] [-d] file.marc\n"; +my $file = shift @ARGV || die "usage: $0 [-n number] [-l limit] [-h] [-d] file.marc\n"; my $marc = new MARC::Fast( marcdb => $file, - debug => $opt{'d'}, + debug => $opt{d}, ); my $min = 1; my $max = $marc->count; -if (my $mfn = $opt{'n'}) { +if (my $mfn = $opt{n}) { $min = $max = $mfn; print STDERR "Dumping $mfn only\n"; +} elsif (my $limit = $opt{l}) { + print STDERR "$file has $max records, using first $limit\n"; + $max = $limit; } else { print STDERR "$file has $max records...\n"; } for my $mfn ($min .. $max) { my $rec = $marc->fetch($mfn) || next; - print Dumper($rec); + print "rec is ",Dumper($rec) if ($opt{d}); print "REC $mfn\n"; foreach my $f (sort keys %{$rec}) { - print "$f\t", join('', $rec->{$f}) ,"\n"; + my $dump = join('', @{ $rec->{$f} }); + $dump =~ s/\x1e$//; + $dump =~ s/\x1f/\$/g; + print "$f\t$dump\n"; } print "\n"; - print Dumper($marc->to_hash($mfn)); + print "hash is ",Dumper($marc->to_hash($mfn)) if ($opt{h}); }