in reply to recursive subdirectories

The -d bit is actually a “file test” operator.   The documentation on this is a bit hard to find, but here's a way:   perldoc -f “-d”

There are a lot of “file finding” packages out there,   and a lot of options even within File::Find.   I suggest that you step back one or two paces and consider what you are trying to accomplish, and then consider what might be the easiest way to do it.   Perhaps you are trying just a little bit too earnestly to get this particular approach to work ... and, “lawdy knows” I’ve done exactly the same thing!   (Show of hands, please?   Thank you.   See what I mean...?)