Actually the thing is that I want to retain the size of the code by inserting the space whereever that particular $pattern exists. The second while is used as there can be any no. of lines before there the pattern is found.
Comment on Re^2: 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;
}