5 |
|
|
6 |
use MARC::Fast; |
use MARC::Fast; |
7 |
use Getopt::Std; |
use Getopt::Std; |
8 |
use Data::Dumper; |
use Data::Dump qw/dump/; |
9 |
|
|
10 |
=head1 NAME |
=head1 NAME |
11 |
|
|
19 |
|
|
20 |
=over 16 |
=over 16 |
21 |
|
|
22 |
=item -n number |
=item -o offset |
23 |
|
|
24 |
dump just record C<number> |
dump records starting with C<offset> |
25 |
|
|
26 |
=item -l limit |
=item -l limit |
27 |
|
|
28 |
import just first C<limit> records |
dump just C<limit> records |
29 |
|
|
30 |
=item -h |
=item -h |
31 |
|
|
40 |
=cut |
=cut |
41 |
|
|
42 |
my %opt; |
my %opt; |
43 |
getopts('dn:l:h', \%opt); |
getopts('do:l:h', \%opt); |
44 |
|
|
45 |
my $file = shift @ARGV || die "usage: $0 [-n number] [-l limit] [-h] [-d] file.marc\n"; |
my $file = shift @ARGV || die "usage: $0 [-o offset] [-l limit] [-h] [-d] file.marc\n"; |
46 |
|
|
47 |
my $marc = new MARC::Fast( |
my $marc = new MARC::Fast( |
48 |
marcdb => $file, |
marcdb => $file, |
65 |
|
|
66 |
for my $mfn ($min .. $max) { |
for my $mfn ($min .. $max) { |
67 |
my $rec = $marc->fetch($mfn) || next; |
my $rec = $marc->fetch($mfn) || next; |
68 |
print "rec is ",Dumper($rec) if ($opt{d}); |
print "rec is ",dump($rec) if ($opt{d}); |
69 |
print "REC $mfn\n"; |
print "REC $mfn\n"; |
70 |
foreach my $f (sort keys %{$rec}) { |
print $marc->last_leader,"\n"; |
71 |
my $dump = join('', @{ $rec->{$f} }); |
print $marc->to_ascii($mfn),"\n"; |
72 |
$dump =~ s/\x1e$//; |
print "hash is ",dump($marc->to_hash($mfn, include_subfields => 1)) if ($opt{h}); |
|
$dump =~ s/\x1f/\$/g; |
|
|
print "$f\t$dump\n"; |
|
|
} |
|
|
print "\n"; |
|
|
print "hash is ",Dumper($marc->to_hash($mfn)) if ($opt{h}); |
|
73 |
} |
} |