-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmarcfix.pl
39 lines (27 loc) · 893 Bytes
/
marcfix.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/perl
# This short script removes breaking 000 fields from NORMARC
# Unix:
# marcfix.pl inputfile.mrc > outputfile.xml
($input) = @ARGV;
use MARC::Batch;
use MARC::Record;
use MARC::Field;
if (not (-f $input)) { die "Input file \"$input\" does not exist!"}
# if (not ($output)) { die "You must specify an output file!"}
my $batch = MARC::Batch->new( 'USMARC', $input );
# turn off strict so process does not stop on errors
$batch->strict_off();
my $rec_count = 0;
while (my $record = $batch->next()) {
$rec_count++;
#get all 000s
my @m000 = $record->field('000');
$record->delete_field(@m000);
print $record->as_usmarc();
}
#print "\n$rec_count records processed\n";
#print "----------------------------\n";
# make sure there weren't any problems.
#if ( my @warnings = $batch->warnings() ) {
# print "\nWarnings were detected!\n", @warnings;
# }