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 single C<mfn> record (same as C<-o mfn -l 1>)
36 dump result of C<to_hash> on record
40 turn debugging output on
44 dump tsv file for TokyoCabinet import
51 getopts('do:l:n:ht', \%opt);
53 my $file = shift @ARGV || die "usage: $0 [-o offset] [-l limit] [-n single_mfn] [-h] [-d] [-t] file.marc\n";
55 my $marc = new MARC::Fast(
60 my $min = $opt{o} || 1;
61 my $max = $marc->count;
63 if (my $mfn = $opt{n}) {
65 print STDERR "Dumping $mfn only\n";
66 } elsif (my $limit = $opt{l}) {
67 print STDERR "$file has $max records, using first $limit\n";
68 $max = $min + $limit - 1;
70 print STDERR "$file has $max records...\n";
73 for my $mfn ($min .. $max) {
74 my $rec = $marc->fetch($mfn) || next;
75 warn "rec is ",dump($rec) if ($opt{d});
77 print "rec\t$mfn\tleader\t", $marc->last_leader, "\t";
78 my $ascii = $marc->to_ascii($mfn);
79 $ascii =~ s{\n}{\t}gs;
83 print $marc->last_leader,"\n";
84 print $marc->to_ascii($mfn),"\n";
86 warn "hash is ",dump($marc->to_hash($mfn, include_subfields => 1)) if ($opt{h});