I am trying to replace the word "test" in a file with the word
"Change" without creating a new file using the following code:
#! /usr/bin/perl -w
open (IN, "+</path/to/file/test.html");
while (<IN>){
s/test/Change/;
print IN;
}
close IN;
The orignal file contains:
test 1
test 2
test 3
and my results are:
test 1
test 2
test 3
test 1
Change 1
test 3
Change 3
I am looking for the results to be:
Change 1
Change 2
Change 3
and that is what I get if I output the print to a new file or to
<STDOUT>.
What am I doing wrong? Any help would be much appreciated.
Thanks in advance