4 use MARC::File::XML ( BinaryEncoding => 'utf-8' );
6 use Unicode::Normalize;
8 my $filetype = $ARGV[0]; # XML or USMARC
9 my $filename = $ARGV[1];
10 if (! $filetype && ! $filename ) { die "./script <USMARC or XML> <filename>\n"; }
14 binmode(STDOUT, ':utf8');
15 binmode(STDIN, ':utf8');
30 print STDERR "Processing " . $ARGV[$argnum] . "\n";
33 open $M, '<:utf8', $ARGV[1];
34 my $batch = MARC::Batch->new($ARGV[0],$M);
37 $batch->warnings_off();
39 while ( my $record = $batch->next() ) {
43 print STDERR "WARNINGS: Record $count : " . join(":",@warnings) . " : continuing...\n" if ( @warnings );
44 my $my_903 = $record->field('903');
45 my $my_903a = $my_903 ? $my_903->subfield('a') : ''; # target bib id's here
46 my @my_961_tags = $record->field('961'); my $bib961u = '';
47 foreach my $my_961 ( @my_961_tags ) {
48 my @subfield_u = $my_961->subfield('u');
49 foreach my $u ( @subfield_u ) {
54 my @tags = $record->field('852');
55 foreach my $tag ( @tags ) {
56 if ($tag->subfield('p')) { # if material_number
59 $record->field('001') ? $record->field('001')->as_string() : '', #bib001
60 $tag->subfield('p') || '', # material_number
61 $tag->subfield('h') || '', # call_number
62 $tag->subfield('c') || '', # copy_location
63 $tag->subfield('9') || '', # price_and_vendor
64 $tag->subfield('b') || '', # subf_b
65 $tag->subfield('x') || '', # subf_x
72 print STDERR "Processed $count records\n";