8 my $conf = {}; # configuration hashref
11 # build exclusion hash
12 open FP, '<', shift or die "Can't open matchset file: $!\n";
16 my ($lead,$sub) = split /\t/;
17 $sub =~ s/\s//g; # any whitespace is extraneous
18 $exclude{$sub} = 1 unless ($sub < $conf->{lowerbound});
22 # strip exclusions from marcxml file
23 open MI, '<', $conf->{input} or die "Can't open input file: $!\n";
24 open MO, '>', $conf->{output} or die "Can't open output file: $!\n";
26 m/tag="$conf->{tag}".+?<subfield code="$conf->{subfield}">(\d+)</;
27 print MO unless $exclude{$1};
35 # set mode on existing filehandles
36 binmode(STDIN, ':utf8');
38 my $rc = GetOptions( $c,
46 show_help() unless $rc;
47 show_help() if ($c->{help});
49 $conf->{tag} = $conf->{tag} || 903;
50 $conf->{subfield} = $conf->{subfield} || 'a';
52 my @keys = keys %{$c};
53 show_help() unless (@ARGV and @keys);
54 for my $key ('output', 'lowerbound', 'input')
55 { push @missing, $key unless $c->{$key} }
57 print "Required option: ", join(', ', @missing), " missing!\n";
64 Usage is: extract_loadset -l BOUND -i INPUTXML -o OUTPUTXML MATCHSET
66 --lowerbound -l Lowest record ID which will be included in the loadset
67 --input -i MARCXML input file
68 --output -o MARCXML output file
69 --tag -t MARC tag to use as identifier (default: 903)
70 --subfield -s Subfield of --tag argument (default: 'a')