X-Git-Url: http://git.rot13.org/?p=MARC-Fast;a=blobdiff_plain;f=scripts%2Fdump_fastmarc.pl;h=dd4897c400413d0069bbb051d108b8a0357b7287;hp=b1d87023e2a77da918a34b2e3ef6e82dcb817d79;hb=4ed177eeead2afff1d64a38fce08780baf679bda;hpb=79218e828e9e2e78f8b8c0f54be1ca9b99937d55 diff --git a/scripts/dump_fastmarc.pl b/scripts/dump_fastmarc.pl index b1d8702..dd4897c 100755 --- a/scripts/dump_fastmarc.pl +++ b/scripts/dump_fastmarc.pl @@ -1,11 +1,11 @@ #!/usr/bin/perl -w use strict; -use blib; +use lib 'lib'; use MARC::Fast; use Getopt::Std; -use Data::Dumper; +use Data::Dump qw/dump/; =head1 NAME @@ -35,12 +35,16 @@ dump result of C on record turn debugging output on +=item -t + +dump tsv file for TokyoCabinet import + =back =cut my %opt; -getopts('do:l:h', \%opt); +getopts('do:l:ht', \%opt); my $file = shift @ARGV || die "usage: $0 [-o offset] [-l limit] [-h] [-d] file.marc\n"; @@ -65,14 +69,16 @@ if (my $mfn = $opt{n}) { for my $mfn ($min .. $max) { my $rec = $marc->fetch($mfn) || next; - print "rec is ",Dumper($rec) if ($opt{d}); - print "REC $mfn\n"; - foreach my $f (sort keys %{$rec}) { - my $dump = join('', @{ $rec->{$f} }); - $dump =~ s/\x1e$//; - $dump =~ s/\x1f/\$/g; - print "$f\t$dump\n"; + warn "rec is ",dump($rec) if ($opt{d}); + if ( $opt{t} ) { + print "rec\t$mfn\tleader\t", $marc->last_leader, "\t"; + my $ascii = $marc->to_ascii($mfn); + $ascii =~ s{\n}{\t}gs; + print "$ascii\n"; + } else { + print "REC $mfn\n"; + print $marc->last_leader,"\n"; + print $marc->to_ascii($mfn),"\n"; } - print "\n"; - print "hash is ",Dumper($marc->to_hash($mfn)) if ($opt{h}); + warn "hash is ",dump($marc->to_hash($mfn, include_subfields => 1)) if ($opt{h}); }