in reply to
File::Find in a loop
The "wanted" sub uses a GLOBAL $dir in your code. (Before I get flamed - what I mean is GLOBAL to the sub. The example below uses a lexical variable that is global to the sub)
In the "for my $dir" loop, $dir is LOCAL to the block enclosed by the "for" loop, so the "wanted" sub cannot see it.
To fix, keep $dir global:
for $dir (@...)...
"I'm fairly sure if they took porn off the Internet, there'd only be one website left, and it'd be called 'Bring Back the Porn!'"
-- Dr. Cox, Scrubs