mndoci has asked for the wisdom of the Perl Monks concerning the following question:
This prints out each line to STDOUT. I can redirect the output to a newfile, but what I want to do is overwrite the original file. What would be the most efficient way to do this? Of course I have the more advanced case where I do not want to touch line #1. As far as I can figure out I need a way to bybass $_[0] and only modify after that but am not quite sure how to do itwhile (<>){ chomp $_; $newline = $_ . "_"; print $newline; print "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: modifying and overwriting a file
by chipmunk (Parson) on May 17, 2001 at 09:16 UTC | |
|
Re: modifying and overwriting a file
by bjelli (Pilgrim) on May 17, 2001 at 12:16 UTC | |
|
Re: modifying and overwriting a file
by jepri (Parson) on May 17, 2001 at 09:08 UTC |