5 use MARC::File::XML ( BinaryEncoding => 'utf-8' );
10 my $split_every = $ARGV[0];
13 binmode(STDOUT, ':utf8');
14 binmode(STDIN, ':utf8');
17 foreach $argnum ( 1 .. $#ARGV ) {
19 open $M, '<:utf8', $ARGV[$argnum];
21 print STDERR "Processing " . $ARGV[$argnum] . "\n";
23 my $batch = MARC::Batch->new('XML', $M);
25 $batch->warnings_off();
28 while ( try { $record = $batch->next() } otherwise { $record = -1 } ) {
29 next if ($record == -1);
32 my $filename = $ARGV[$argnum] . ".split." . floor( $count / $split_every ) . ".xml";
34 open FILE, ">>$filename";
35 binmode(FILE, ':utf8');
36 print FILE $record->as_xml();
41 unless ($count % 1000) {
42 print STDERR "$count\r"
46 print STDERR "Processed $count records.\n";