Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re^2: Delete files if they match help!by afoken (Chancellor) |
on Jan 07, 2011 at 14:59 UTC ( [id://881085]=note: print w/replies, xml ) | Need Help?? |
TOCTOU, but why? unlink() won't kill your grandma if the file to be deleted does not exist (any more). It will just generate an error ("No such file or directory"). It also generates an error ("Is a directory") when you attempt to delete a directory instead of a plain file (unless you are root, have started perl with the -U flag, and your OS supports unlinking a directory). So, unlink(), check $!, TOCTOU problem gone. Alexander
-- Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
In Section
Seekers of Perl Wisdom
|
|