in reply to Rewriting into file

You can in this case, but you should just forget about doing that. The general rule is: you cannot alter files. Learn the four step process posted above.

After you learn to manually do the 4-step process, then you can use a shortcut for that process that perl provides:

use strict; use warnings; use 5.010; use English; { #Turn on inplace editing for <> operator, no backup file: local $INPLACE_EDIT = ""; local @ARGV = "./test/data.txt"; #...or list file name on command line while(my $line = <>) { $line =~ s/hello/goodbye/; #alter the line print $line; #...then print() it (*required*) } }

Replies are listed 'Best First'.
Re^2: Rewriting into file
by Anonymous Monk on Jun 20, 2011 at 10:06 UTC
      Hi All, I completed the above task. Thanks All for the help.