From d7d5ef02fd84e4a20f79d317c2d5e8f952c773c5 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Wed, 24 Sep 2008 12:43:50 +0000 Subject: [PATCH] for now --- miker-filter_incoming.pl | 119 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 119 insertions(+), 0 deletions(-) create mode 100644 miker-filter_incoming.pl diff --git a/miker-filter_incoming.pl b/miker-filter_incoming.pl new file mode 100644 index 0000000..203d525 --- /dev/null +++ b/miker-filter_incoming.pl @@ -0,0 +1,119 @@ +#!/usr/bin/perl +use warnings; +use strict; + +use Getopt::Long; +#use Time::HiRes qw/time/; +#use MARC::Record; +#use MARC::File::XML ( BinaryEncoding => 'utf-8' ); + +# configuration hashref +my $conf = (); +initialize($conf); + +my $idfile = shift; +my $marcfile = shift; +my $import = shift; +my $shelve = shift; + +my %id; + +open F, "<$idfile"; +while () { + chomp; + $id{$_} = 1; +} + +close F; + +my $M; +open $M, '<:utf8', $marcfile; +open $I, '>:utf8', $import; +open $S, '>:utf8', $shelve; + +my $starttime = time; +my $count = 0; +my $icount = 0; +my $scount = 0; +while (<$M>) { + /tag="903" ind1=" " ind2=" ">.*?(\d+){help}); + + $c->{'incoming-tag'} = 903; + $c->{'incoming-subfield'} = 'a'; + $c->{'incoming-matchfile'} = ''; + $c->{'incoming-nomatchfile'} = ''; + $c->{'incumbent-tag'} = 901; + $c->{'incumbent-subfield'} = 'a'; + $c->{'incumbent-matchfile'} = ''; + $c->{'incumbent-nomatchfile'} = ''; + my @keys = keys %{$c}; + show_help() unless (@ARGV and @keys); + for my $key ('renumber-from', 'tag', 'subfield', 'output') + { push @missing, $key unless $c->{$key} } + if (@missing) { + print "Required option: ", join(', ', @missing), " missing!\n"; + show_help(); + } + +} + + +=head2 show_help + +Display usage message when things go wrong + +=cut + +sub show_help { +print < -o Output filename + +Any number of input files may be specified; one output file will result. +HELP +exit 1; +} -- 1.7.2.5