Marcello has asked for the wisdom of the Perl Monks concerning the following question:
Is there a solution so I can detect that the file does not exists anymore? Both print and syswrite report no errors. Ofcourse I could use (-e $filename) but there's always this chance that the file is removed between the test and the print.use strict; use warnings; my $filename = 'logfile.txt'; open(my $handle, '>>', $filename) or die; unlink($filename); print $handle "First line\n"; syswrite($handle, "Second line\n"); close($handle);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Logging to a filehandle of a deleted file
by varian (Chaplain) on Feb 28, 2007 at 10:18 UTC | |
by Moron (Curate) on Feb 28, 2007 at 15:02 UTC | |
|
Re: Logging to a filehandle of a deleted file
by idsfa (Vicar) on Feb 28, 2007 at 14:30 UTC | |
|
Re: Logging to a filehandle of a deleted file
by cdarke (Prior) on Feb 28, 2007 at 14:11 UTC | |
|
Re: Logging to a filehandle of a deleted file
by Anonymous Monk on Feb 28, 2007 at 10:24 UTC | |
by Fletch (Bishop) on Feb 28, 2007 at 13:56 UTC |