Upgrade script :
[koha.git] / misc / dumpmarc.pl
1 #!/usr/bin/perl
2 # small script that dumps an iso2709 file.
3
4
5 use strict;
6
7 # Koha modules used
8 use MARC::File::USMARC;
9 use MARC::Record;
10 use MARC::Batch;
11
12 use Getopt::Long;
13 my ( $input_marc_file,$number) = ('',0);
14 my $version;
15 GetOptions(
16     'file:s'    => \$input_marc_file,
17     'n' => \$number,
18     'v' => \$version
19 );
20
21 if ($version || ($input_marc_file eq '')) {
22         print <<EOF
23 small script to dump an iso2709 file.
24 parameters :
25 \tv : this version/help screen
26 \tfile /path/to/file/to/dump : the file to dump
27 \tn : the number of the record to dump. If missing, all the file is dumped
28 SAMPLE : ./dumpmarc.pl -file /home/paul/koha.dev/local/npl -n 1
29 EOF
30 ;
31 die;
32 }
33
34 my $batch = MARC::Batch->new( 'USMARC', $input_marc_file );
35 $batch->warnings_off();
36 $batch->strict_off();
37 my $i=1;
38 while ( my $record = $batch->next() ) {
39         print "\n".$record->as_formatted() if ($i eq $number || $number eq 0);
40         $i++;
41 }
42 print "\n==================\n$i record parsed\n";