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
In reply to Re: Subroutine to delete one file and copy one file to another
by Monk::Thomas
in thread Subroutine to delete one file and copy one file to another
by shroh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |