On Tue, Nov 22, 2011 at 15:33, tshtatland <tshtatl...@gmail.com> wrote:
> On Nov 22, 4:27 pm, carni...@gmail.com (Mark Wagner) wrote:
>> I want to update a status file, similar to this:
>>
>> open OUTFILE, ">", "status.txt";
>> print OUTFILE "$last_date\n";
>> close OUTFILE;
>>
>> However, if something goes wrong (e.g. the disk is full), this code
>> will replace "status.txt" with an empty file.  How can I update the
>> file while preserving the previous contents if something goes wrong?
>>
>> --
>> Mark Wagner
>
> Have you considered appending?

That would work, but it would introduce the need to periodically prune
the file, and would make reading the file much more complicated: if
the disk fills up, the final line could well be a fractional
timestamp, so I'd need to verify that what I'd just read was valid.

-- 
Mark Wagner

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to