my $dir = "wherever"; my %options = ( preprocess => \&filterOutSubdir, wanted => \&wanted, ); finddepth(\%options, $dir);