Perl-Sensitive Sunglasses | |
PerlMonks |
Re: Problem with deleting the first n characters on a lineby Cubes (Pilgrim) |
on Jul 18, 2001 at 18:13 UTC ( [id://97665]=note: print w/replies, xml ) | Need Help?? |
You're not resetting your file position before writing back into FOUND (and even if you did, I don't think this code would do what you expect because the new string you write out is shorter than the original).
The quick 'n' easy way: open up a second file for output. Loop through the entire input file, changing lines as necessary before printing them to the output file. At the end, remove the original and rename your output file to the original's filename.
In Section
Seekers of Perl Wisdom
|
|