in reply to Subroutine to delete one file and copy one file to another
I would add a safeguard:
if (not -d $delTemp) { unlink $delTemp; } else { warn "Whoaaaah. Hold it. $delTemp is a directory!\n"; }
Ideally this would never trigger, but if it does you have prevented some serious trouble:
unlink will not attempt to delete directories unless you are superuser and the -U flag is supplied to Perl. Even if these conditions are met, be warned that unlinking a directory can inflict damage on your filesystem. Finally, using unlink on directories is not supported on many operating systems. Use rmdir instead.
-- http://perldoc.perl.org/functions/unlink.html
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Subroutine to delete one file and copy one file to another
by afoken (Chancellor) on Jul 21, 2015 at 16:50 UTC |