Perl: the Markov chain saw | |
PerlMonks |
Re: Using read/write to update a fileby MidLifeXis (Monsignor) |
on Oct 14, 2014 at 18:53 UTC ( [id://1103790]=note: print w/replies, xml ) | Need Help?? |
You will likely need seek, tell, print (with a filehandle argument), and possibly truncate. Unless the replacement is the same length or shorter (and even then you still might), you will also need to write to a temporary file, and not just the original file, doing a rename after closing both files. If you do not (or if you don't use the Tie::File suggestion above), you risk corruption or truncation of the data file. --MidLifeXis
In Section
Seekers of Perl Wisdom
|
|