in reply to Re^2: Suppress 'Can't chdir to' warnings for File::Find
in thread Suppress 'Can't chdir to' warnings for File::Find

My gut on the performance hit is stats the item in question twice. I could be COMPLETELY wrong on that though.

Replies are listed 'Best First'.
Re^4: Suppress 'Can't chdir to' warnings for File::Find
by stevieb (Canon) on Apr 29, 2016 at 13:12 UTC

    There's a feature with stat() where it caches the item being tested on first call, to reduce overhead that would likely help reduce checking time. Note the _ at the end of the one-liner below. That's the cached item.

    perl -wMstrict -E 'say -f "utf.pl" && say -e _'

    Also, one could also look at the no_chdir => 1 feature of File::Find, however I don't know if one would get different warnings in that case, or if it'd just fail silently and move along when it encountered a restricted dir.