There's a few bits of your sample code that don't seem right:
- There's no need to chomp the filename. (harmless though)
- It's odd that you should specify $_ in the pattern match, since
you appear to understand how to use it as the default for the split
command later. (also harmless)
- Why are you splitting the filename on whitespace? The variable $_
contains only one filename, because the subroutine is being called once
for each file. It looks like you think that $_ contains a list of filenames...
- Even so, I don't see why your code wouldn't recurse.
It just doesn't do what you want.
Your test sub could be written more simply:
sub get_good_int {
next if /^unknown/;
print "My filename is: $_\n";
}
Something closer to being useful might be this:
use File::Find;
use File::Basename;
find (\get_good_int, '/nfs/export/netflow/intermediate');
sub get_good_int {
next if /^unknown/;
# If the directory path includes this type of dir
if ($File::Find::dir =~ m#/questionable-\d{6}-\d{6}#) {
myfunc1($_);
}
# If it contains this other type of dir
elsif ($File::Find::dir =~ m#/\d{6}-\d{6}#) {
myfunc2($_);
}
}
buckaduck