3 use MARC::File::XML ( BinaryEncoding => 'utf-8' );
5 use Unicode::Normalize;
7 my $filename = $ARGV[0];
9 my $subfield1 = $ARGV[2];
11 my $subfield2 = $ARGV[4];
13 die "required arguments: filename tag1 subfield1 tag2 subfield2\n" if (! ($filename && $tag1 && $subfield1 && $tag2 && $subfield2) );
17 binmode(STDOUT, ':utf8');
18 binmode(STDIN, ':utf8');
20 print STDERR "Processing $filename\n";
22 my $batch = MARC::Batch->new('XML',$filename); $batch->strict_off(); $batch->warnings_off();
24 while ( my $record = $batch->next() ) {
28 print STDERR "WARNINGS: Record $count : " . join(":",@warnings) . " : continuing...\n" if ( @warnings );
30 my @tags1 = (); if ($record->field($tag1)) { @tags1 = $record->field($tag1); } else { next; }
32 foreach my $f1 ( @tags1 ) {
33 if ($f1->subfield($subfield1)) {
34 my @subfields1 = $f1->subfield($subfield1);
35 foreach my $s1 ( @subfields1 ) {
36 #***********************************************************************************************************************
38 my @tags2 = (); if ($record->field($tag2)) { @tags2 = $record->field($tag2); } else { next; }
40 foreach my $f2 ( @tags2 ) {
41 if ($f2->subfield($subfield2)) {
42 my @subfields2 = $f2->subfield($subfield2);
43 foreach my $s2 ( @subfields2 ) {
49 #***********************************************************************************************************************
54 print STDERR "Processed $count records\n";