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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.