8 use Data::Dump qw/dump/;
12 dump_fastmarc.pl - display MARC records
16 dump_fastmarc.pl /path/to/dump.marc
24 dump records starting with C<offset>
28 dump just C<limit> records
32 dump result of C<to_hash> on record
36 turn debugging output on
40 dump tsv file for TokyoCabinet import
47 getopts('do:l:ht', \%opt);
49 my $file = shift @ARGV || die "usage: $0 [-o offset] [-l limit] [-h] [-d] file.marc\n";
51 my $marc = new MARC::Fast(
58 my $max = $marc->count;
60 if (my $mfn = $opt{n}) {
62 print STDERR "Dumping $mfn only\n";
63 } elsif (my $limit = $opt{l}) {
64 print STDERR "$file has $max records, using first $limit\n";
67 print STDERR "$file has $max records...\n";
70 for my $mfn ($min .. $max) {
71 my $rec = $marc->fetch($mfn) || next;
72 warn "rec is ",dump($rec) if ($opt{d});
74 print "rec\t$mfn\tleader\t", $marc->last_leader, "\t";
75 my $ascii = $marc->to_ascii($mfn);
76 $ascii =~ s{\n}{\t}gs;
80 print $marc->last_leader,"\n";
81 print $marc->to_ascii($mfn),"\n";
83 warn "hash is ",dump($marc->to_hash($mfn, include_subfields => 1)) if ($opt{h});