adding 2 images for npl/ccfls opac
[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,$nowarning) = ('',0);
14 my $version;
15 GetOptions(
16     'file:s'    => \$input_marc_file,
17     'n:s' => \$number,
18     'v' => \$version,
19     'w' => \$nowarning,
20 );
21
22 warn "NUM : $number\n";
23 if ($version || ($input_marc_file eq '')) {
24         print <<EOF
25 small script to dump an iso2709 file.
26 parameters :
27 \tv : this version/help screen
28 \tfile /path/to/file/to/dump : the file to dump
29 \tn : the number of the record to dump. If missing, all the file is dumped
30 \tw : warning and strict off. If your dump fail, try -w option. It it works, then, the file is iso2709, but a buggy one !
31 SAMPLE : ./dumpmarc.pl -file /home/paul/koha.dev/local/npl -n 1
32 EOF
33 ;
34 die;
35 }
36
37 my $batch = MARC::Batch->new( 'USMARC', $input_marc_file );
38 $batch->warnings_off() unless $nowarning;
39 $batch->strict_off() unless $nowarning;
40 my $i=1;
41 while ( my $record = $batch->next() ) {
42         print "\nNUMBER $i =>\n".$record->as_formatted() if ($i eq $number || $number eq 0);
43         $i++;
44 }
45 print "\n==================\n$i record parsed\n";