So for the program I am writing, what I would like for it to do is search through all of the subdirectories within a directory. If the subdirectory name contains a word, let’s say “foo”, then the program will open this subdirectory and perform a function on the files within the subdirectory. Can anybody give me some help on how to go about this? it also needs to be recursive. Thanks in advance
Share
This can be done using the
File::Findmodule, but I believePath::Classis superior even though it isn’t a core module and will likely need installing.This program finds the files wanted and calls
processto process them. At present theprocesssubroutine simply prints the name of the file for testing.Update
If you prefer, this program performs the same task using
File::Find.Update
As requested, here is a further solution using
Path::Class::Rulefor comparison. As daxim suggested the code is a little shorter.