You don't have to follow perldoc File::Find too literally, you can make it look like an ordinary subroutine.
You don't need your foreach, you can feed find() an array. I searched for something that exists on my system ...
use File::Find; my (@good_dirs) = ( "/home", "/var" ); my $ltotal = 0; File::Find::find({wanted => \&wanted}, @good_dirs); print "\nFound a total of $ltotal instances.\n"; sub wanted { my ($dev,$ino,$mode,$nlink,$uid,$gid); if ((($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) && -d _ && /^tmp\z/s ) { $ltotal++; print "$ltotal $File::Find::name\n"; } }
Generates:
1 /home/tomdlux/tmp 2 /home/tomdlux/Tech/Perl/tmp 3 /home/tomdlux/.gimp-1.2/tmp 4 /home/tomdlux/.ee/minis/tmp 5 /home/tomdlux/.ee/minis/home/tomdlux/tmp 6 /var/tmp Found a total of 6 instances.
Is it possible you only have three directories named 'class'?
In reply to Re: Problems using File::Find
by TomDLux
in thread Problems using File::Find
by thewalledcity
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |