4 |
use blib; |
use blib; |
5 |
|
|
6 |
use MARC::Fast; |
use MARC::Fast; |
7 |
|
use Getopt::Std; |
8 |
use Data::Dumper; |
use Data::Dumper; |
9 |
|
|
10 |
my $file = shift @ARGV || die "usage: $0 file.marc\n"; |
my %opt; |
11 |
my $debug = shift @ARGV; |
getopts('dn:', \%opt); |
12 |
|
|
13 |
|
my $file = shift @ARGV || die "usage: $0 [-n number] [-d] file.marc\n"; |
14 |
|
|
15 |
my $marc = new MARC::Fast( |
my $marc = new MARC::Fast( |
16 |
marcdb => $file, |
marcdb => $file, |
17 |
debug => $debug, |
debug => $opt{'d'}, |
18 |
); |
); |
19 |
|
|
|
print STDERR "$file has ",$marc->count," records...\n\n"; |
|
20 |
|
|
21 |
for my $mfn (1 .. $marc->count) { |
my $min = 1; |
22 |
|
my $max = $marc->count; |
23 |
|
|
24 |
|
if (my $mfn = $opt{'n'}) { |
25 |
|
$min = $max = $mfn; |
26 |
|
print STDERR "Dumping $mfn only\n"; |
27 |
|
} else { |
28 |
|
print STDERR "$file has $max records...\n"; |
29 |
|
} |
30 |
|
|
31 |
|
for my $mfn ($min .. $max) { |
32 |
my $rec = $marc->fetch($mfn) || next; |
my $rec = $marc->fetch($mfn) || next; |
33 |
|
print Dumper($rec); |
34 |
print "REC $mfn\n"; |
print "REC $mfn\n"; |
35 |
foreach my $f (sort keys %{$rec}) { |
foreach my $f (sort keys %{$rec}) { |
36 |
print "$f\t",$rec->{$f},"\n"; |
print "$f\t", join('', $rec->{$f}) ,"\n"; |
37 |
} |
} |
38 |
print "\n"; |
print "\n"; |
39 |
|
print Dumper($marc->to_hash($mfn)); |
40 |
} |
} |