So, I recently noticed a use of opendir in a script, and would like to change it slightly so that it returns files in the subfolders of a directory as well as files in the directory itself. After investigating, I haven’t been able to find any sort of recursive option for opendir, and have had trouble getting glob to return a scalar. So, rather than fudge around with either one more, I figured it would be more prudent to just ask: what is the standard way to get a handle to all files in a dir and its subdirs?
Share
The classic way is with File::Find, which has the advantage of being a core module, but it can be a bit of a pain. If you’re able to use a third-party module, File::Util is quite handy: