in reply to Re^2: Replacing the pattern to search for
in thread Replacing the pattern to search for
use strict; my $file_name="c:\\temp.txt"; open (FH,"$file_name"); my $pattern="some thing"; my $c=0; my $space=' '; my $line; while(<FH>) { $line=$_; #current line $c++; #counts the number of lines $space=' ' x $c .' ' x length($pattern); #pattern that has to be r +eplaced $line=~s/$pattern/$space/i; }
|
|---|