10 open MARC, '<', 'incoming.marc.xml';
11 open NUMARC, '>', 'incoming.clean.marc.xml';
13 until ($count == ($skip - 1)) {
17 printf("\rSpinning on to record %s (%2.2f%%)", $skip, ($count / $skip *100))
18 unless ($count % 1000);
20 print "\nScrubbing resumes...\n" if $skip;
24 while (my $line2 = <MARC>) {
26 # catch empty datafield elements
27 if ($line1 =~ m/<datafield tag="..." ind1="." ind2=".">/) {
28 if ($line2 =~ m|</datafield>|) {
35 # clean up tags with spaces in them
36 $line1 =~ s/tag=" /tag="00/g;
37 $line1 =~ s/tag=" /tag="0/g;
38 $line1 =~ s/tag="-/tag="0/g;
39 $line1 =~ s/tag="(\d\d) /tag="0$1/g;
41 # subfields can't be non-alphanumeric
42 die "Junk in subfield at line $count: $line1"
43 if $line1 =~ /<subfield code="[^[:alnum:]]"/;