in reply to Logging to a filehandle of a deleted file
Note that while your filehandle remains open you can still write to the deleted file. Deleted files will not be visible in directory listings but the open handle would show up on the systems list of open handles (e.g. the command lsof in Lunix and Unix systems would reveal them, provided you have enough system privileges).use strict; use warnings; my $filename = 'logfile.txt'; my $backupfile = 'logfile.backup'; open(my $handle, '>>', $filename) or die; link $filename, $backupfile; unlink($filename); print $handle "First line\n"; syswrite($handle, "Second line\n"); close($handle); rename $backupfile,$filename; # ok to fail if $filename still exists unlink $backupfile;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Logging to a filehandle of a deleted file
by Moron (Curate) on Feb 28, 2007 at 15:02 UTC |