7 # configuration hashref
13 open F, "<", $conf->{idfile};
21 open $M, '<:utf8', $conf->{marcfile}
22 or die "Can't open marcfile '",$conf->{marcfile},"'\n";
23 open $I, '>:utf8', $conf->{'output-import'}
24 or die "Can't open import file '",$conf->{'output-import'},"'\n";
25 open $S, '>:utf8', $conf->{'output-shelved'}
26 or die "Can't open shelf file '",$conf->{'output-shelve'},"'\n";
29 my $tag = $conf->{tag};
30 my $sub = $conf->{subfield};
32 /tag="$tag" ind1=" " ind2=" ">.*?<subfield code="$sub">(\d+)</;
33 if ($conf->{mode} eq "exclude") {
34 print $S $_ if ($id{$1});
35 print $I $_ unless ($id{$1});;
37 print $S $_ unless ($id{$1});
38 print $I $_ if ($id{$1});;
42 unless ($conf->{count} % 100) {
43 print STDERR "\rProcessed: ",$conf->{count};
49 Performs boring script initialization. Handles argument parsing,
58 # set mode on existing filehandles
59 binmode(STDIN, ':utf8');
61 my $rc = GetOptions( $c,
69 'output-shelved|os=s',
72 show_help() unless $rc;
73 show_help() if ($c->{help});
75 my @keys = keys %{$c};
76 for my $key ('mode', 'idfile', 'marcfile', 'tag', 'subfield',
77 'output-import', 'output-shelved')
78 { push @missing, $key unless $c->{$key} }
80 print "Required option: ", join(', ', @missing), " missing!\n";
83 unless ($c->{mode} eq "include" or $c->{mode} eq "exclude") {
84 print "Unknown run mode '", $c->{mode}, "'\n";
92 Display usage message when things go wrong
100 --mode=MODE Runmode to use (exclude, include; usually exclude)
101 --idfile -i File of record ids to use as source for matchpoints
102 --marcfile -m MARCXML source file
103 --tag -t MARC tag to use as matchpoint (903 when matching
104 incoming records, 901 when matching incumbents)
105 --subfield -s Subfield of tag to use ('a' for incoming, 'c'
107 --output-import -oi Output MARCXML file for records to be imported
108 --output-shelved -os Output MARCXML file for records to be ignored
110 If '--mode=exclude' is specified, the record ids in the file specified
111 by -idfile will be used as EXCLUSION data.
113 That is, the given record ids will be treated as records which match
114 incumbent records, are being compressed into existing data, and so
115 WILL NOT be imported. The --output-import file will contain records
116 whose ids DO NOT occur in --idfile; --output-shelved will contain the
117 records which DO occur.
119 If '--mode=include' is specified, the reverse occurs.