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