Eliyah Kilada wrote:
Hi,
is there a method to _/directly/_ make:
while (< FIN>)
{
$_ =~ s/xxxx/xxxxx/g;
}
modify FIN?!
i.e., I need to make modifications in the same file I read from.
Thanks And Regards,
Eliyah
yeah, I do this often right at the command line:
perl -pi.bak -e 's/xxxx/xxxxx/g;' filetochange
this automatically creates a backup file named filetochange.bak
to edit the file in-place (once you're sure you have the regex correct),
you need simply alter the line to read:
perl -pi -e 's/xxxx/xxxxx/g;' filetochange
see perldoc perlrun for more details on -p -n and -i switches.
my most often used example is nativizing line-endings in text files:
perl -pi -e 's#\015\012|\015|\012#\n#' *.txt
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>