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*) } }
In reply to Re: Rewriting into file
by 7stud
in thread Rewriting into file
by pr09
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |