Re: Safely updating a file

2011-11-25 Thread C.DeRykus
On Nov 22, 1:39 pm, shawnhco...@gmail.com (Shawn H Corey) wrote: On 11-11-22 04:27 PM, 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),

Re: Safely updating a file

2011-11-23 Thread tshtatland
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

Re: Safely updating a file

2011-11-23 Thread Uri Guttman
On 11/22/2011 06:33 PM, tshtatland wrote: Have you considered appending? he seems to want a single timestamp in the file. appending would add one timestamp for each call. how would this do what the OP wanted? and File::Slurp has an append_file sub which also makes appending much easier

Re: Safely updating a file

2011-11-23 Thread Mark Wagner
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.

Re: Safely updating a file

2011-11-23 Thread Shawn H Corey
On 11-11-23 03:31 PM, Mark Wagner wrote: 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

Safely updating a file

2011-11-22 Thread Mark Wagner
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

Re: Safely updating a file

2011-11-22 Thread Shawn H Corey
On 11-11-22 04:27 PM, 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

Re: Safely updating a file

2011-11-22 Thread Jim Gibson
On 11/22/11 Tue Nov 22, 2011 1:27 PM, Mark Wagner carni...@gmail.com scribbled: 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

Re: Safely updating a file

2011-11-22 Thread Uri Guttman
On 11/22/2011 04:27 PM, 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