6 #use Time::HiRes qw/time/;
8 #use MARC::File::XML ( BinaryEncoding => 'utf-8' );
10 # configuration hashref
30 open $M, '<:utf8', $marcfile;
31 open $I, '>:utf8', $import;
32 open $S, '>:utf8', $shelve;
39 /tag="901" ind1=" " ind2=" ">.*?<subfield code="c">(\d+)</;
49 unless ($count && $count % 100) {
50 print STDERR "\r$count\t(shelved: $scount, import: $icount)\t". $count / (time - $starttime);
56 Performs boring script initialization. Handles argument parsing,
65 # set mode on existing filehandles
66 binmode(STDIN, ':utf8');
68 my $rc = GetOptions( $c,
71 'incoming-tag|incot=i',
72 'incoming-subfield|incos=s',
73 'incumbent-tag|incut=i',
74 'incumbent-subfield|incus=s',
78 show_help() unless $rc;
79 show_help() if ($c->{help});
81 $c->{'incoming-tag'} = 903;
82 $c->{'incoming-subfield'} = 'a';
83 $c->{'incoming-matchfile'} = '';
84 $c->{'incoming-nomatchfile'} = '';
85 $c->{'incumbent-tag'} = 901;
86 $c->{'incumbent-subfield'} = 'a';
87 $c->{'incumbent-matchfile'} = '';
88 $c->{'incumbent-nomatchfile'} = '';
89 my @keys = keys %{$c};
90 show_help() unless (@ARGV and @keys);
91 for my $key ('renumber-from', 'tag', 'subfield', 'output')
92 { push @missing, $key unless $c->{$key} }
94 print "Required option: ", join(', ', @missing), " missing!\n";
103 Display usage message when things go wrong
109 Usage is: $0 [REQUIRED ARGS]
111 --renumber-from=N -rf First id# of new sequence
112 --tag=N -t Which tag to use
113 --subfield=X -s Which subfield to use
114 --output=<file> -o Output filename
116 Any number of input files may be specified; one output file will result.