From: Shawn Boyette Date: Wed, 24 Sep 2008 18:57:09 +0000 (+0000) Subject: improved sub command X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=commitdiff_plain;h=3977d3f57dde51520e22e6cb2e1a7cbcb0ae2cfc improved sub command --- diff --git a/marc-cleanup b/marc-cleanup index fd7e5b9..3cf7198 100755 --- a/marc-cleanup +++ b/marc-cleanup @@ -108,7 +108,7 @@ while (my $line = getline()) { } print $NUMARC "\n"; print $EXMARC "\n"; -print $OUT "\nDone\n" +print $OUT "\nDone\n"; =head2 edit @@ -170,7 +170,7 @@ sub getline { sub write_record { my ($FH) = @_; - print $FH '',"\n"; + print $FH '',"\n"; print $FH @record; print $FH "\n"; } @@ -186,8 +186,13 @@ sub update_linecontext { #----------------------------------------------------------------------------------- sub substitute { - my ($line_in, $from, $to) = @_; - $from = join("\\", '', split(//,$from)); + my ($line_in, $ofrom, $to) = @_; + my $from = ''; + for my $char (split(//,$ofrom)) { + $char = "\\" . $char if ($char =~ /\W/); + $from = join('', $from, $char); + } + print $OUT "\n$from\n"; $record[-1] =~ s/$from/$to/; $linecontext[3] = $record[-1]; print_linecontext();