in reply to Replacing the pattern to search for

Not sure what exactly you're trying to do, but it looks like you want pattern replaced with line number (starting at 1) + pattern length number of spaces. You also want to do this only once per line. In addition, the file is specified as being up to 100000 bytes, which means the file can be loaded into memory all at once instead of being read line by line. The following should work:
use strict; use warnings; my $path = "c:\\temp.txt"; my $pattern = "some thing"; my $handle; open($handle, $path); my @data = <$handle>; close($handle); my $c = length($pattern); for (@data) { $c++; $_ =~ s/$pattern/' ' x $c/ei; } open($handle, ">$path"); print $handle @data; close($handle);