utf8 pragma
[migration-tools.git] / spot_check.pl
1 #!/usr/bin/perl
2 use open ':utf8';
3 use MARC::Batch;
4 use MARC::Record;
5 use MARC::File::XML ( BinaryEncoding => 'utf-8' );
6 use MARC::Field;
7
8 my $count = 0;
9
10 binmode(STDOUT, ':utf8');
11 binmode(STDIN, ':utf8');
12
13 foreach $argnum ( 0 .. $#ARGV ) {
14
15         print STDERR "Processing " . $ARGV[$argnum] . "\n";
16
17         my $batch = MARC::Batch->new('XML',$ARGV[$argnum]);
18         $batch->strict_off();
19         $batch->warnings_off();
20
21     my $last_successful_record;
22
23     eval {
24         while ( my $record = $batch->next() ) {
25
26             $count++; 
27
28             $last_successful_record = $record->as_xml();
29
30             print STDERR "WARNINGS: Record $count : " . join(":",@warnings) . " : continuing...\n" if ( @warnings );
31
32         }
33     };
34     print STDERR "Processed $count records.  Last successful record = " . $last_successful_record . "\n";
35     warn $@ if $@;
36 }