my $term = new Term::ReadLine 'yaz-cleanup';
my $OUT = $term->OUT || \*STDOUT;
-my $conf = {}
+my $conf = {};
my $count = 0;
my $reccount = 0;
}
if ($line =~ m/<datafield tag="(.{3})"/) {
my $tag = $1;
- if ($trash{$tag} or ($conf->{autoscrub} and $tag =~ /\D/) {
+ if ($trash{$tag} or ($conf->{autoscrub} and $tag =~ /\D/)) {
$istrash = 1;
next
}
@record = @trimmed;
}
+ # scrub newlines
+ unless ($conf->{nocollapse}) {
+ s/\n// for (@record);
+ }
+
# add 903(?) with new record id
if ($conf->{'renumber-from'}) {
print $FH '<datafield tag="', $conf->{'renumber-tag'}, '"><subfield code="a">',
}
# remove original id sequence tag from trash hash if we know it
- $trash_add($conf->{'original-tag'}, 1)
+ trash_add($conf->{'original-tag'}, 1)
if ($conf->{'original-tag'} and $trash{$conf->{'original-tag'}});
}
my $rc = GetOptions( $c,
'autoscrub|a',
- 'exception|e=s',
+ 'exception|x=s',
'output|o=s',
'nocollapse|n',
'renumber-from|rf=i',
# defaults
$c->{output} = 'incoming.cleaned.marc.xml' unless defined $c->{output};
$c->{exception} = 'incoming.exception.marc.xml' unless defined $c->{exception};
- $c->{'renumber-tag'} = 903 unless defined $c->{exception};
+ $c->{'renumber-tag'} = 903 unless defined $c->{'renumber-tag'};
my @keys = keys %{$c};
show_help() unless (@ARGV and @keys);
sub show_help {
print <<HELP;
+Usage is: $0 [OPTIONS] <filelist>
+Options
+ --output -o Cleaned MARCXML output filename (default: incoming.cleaned.marc.xml)
+ --exception -x Exception (dumped records) MARCXML filename (incoming.exception.marc.xml)
HELP
+exit;
}