Can't you just do this?
if (-e $filepath) { ... } [download]
In reply to Re: opendir slower than ls on large dirs? by TedPride in thread opendir slower than ls on large dirs? by Anonymous Monk