From 3977d3f57dde51520e22e6cb2e1a7cbcb0ae2cfc Mon Sep 17 00:00:00 2001 From: Shawn Boyette Date: Wed, 24 Sep 2008 18:57:09 +0000 Subject: [PATCH] improved sub command --- marc-cleanup | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-) 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(); -- 1.7.2.5