in reply to Find and Replace from File List

I am not sure what you are trying to accomplish. But I do find the following code rather strange. $pattern actually makes no difference here because the value of $pattern is never used in a statement related to output. I figure you could delete all lines involving $pattern.
my($pattern) = 0; while (<INPUT>) { if ($_ =~ s/$searchPattern1/$replacePattern1/g) { $pattern = 1; } elsif ($_ =~ s/$searchPattern2/$replacePattern2/g) { $pattern = 2; } elsif ($_ =~ s/$searchPattern3/$replacePattern3/g) { $pattern = 3; } print OUTPUT $_; }

Replies are listed 'Best First'.
Re^2: Find and Replace from File List
by PyrexKidd (Monk) on May 28, 2010 at 15:48 UTC

    $pattern was used as part of another script.

    I did remove it as it's unnecessary for this code.

    Thanks for the advice.