in reply to Write contents of a file, whilst reading from another file
One way is to open 2 filehandles thus:
use strict; open(my $reader, '<', 'file.to.read'); open(my $writer, '>', 'file.to.write); # will be truncated while(<$reader>) { # do desired mangling here print $writer "$_"; }
This will copy file.to.read into file.to.write unchanged.
If you do stuff in the while where the comment is before writing then print the variable you want into the new file you have a filter.
|
|---|