I m trying to specify a directory, and recursively find every file in the sub-directories. After find
chdir s into a directory, I want to do some processing before find
reads the files. Here is a simplified snippet that demonstrates the problem. It doesn t recurse into the subdirectories, but it looks like it should. I can verify that the sub-dirs and files exist because if I call find
without the preprocess key then I get the listing. I haven t been using Perl for that long so I m kind of stumped.
find({
wanted => &wanted,
preprocess => &preprocess
}, "/home/nelson/invoices/");
# function definitions
sub wanted {
print "Calling wanted...
";
print " " . $File::Find::name . "
";
}
sub preprocess{
print "Calling preprocess...
";
print " " . $File::Find::dir . "
";
}
这里是产出。
Calling wanted...
/home/nelson/invoices
Calling preprocess...
/home/nelson/invoices
Calling wanted...
/home/nelson/invoices/1