The Ghost wrote:
So far I did this:

#!/usr/bin/perl

use File::Find;
my $totalLines;
    find(\&wanted, '@directories');
    sub wanted {
unless ($_=~m/.html|.mas|.pl|.txt$/i) {return 0;} #filter the kinds of files you want
     open FILE, "<$File::Find::name";
     print "$_: ";
        my @lines=<FILE>;
    print "$#lines\n";
$totalLines+=$#lines; #wanted's value is ignored so we have to do this here.

$#lines is the index of the last entry in @lines. scalar( @lines ) is the number of items in the array. Normally, $#lines + 1 == scalar( @lines ). I think you should use scalar( @lines ) here.

        return;}
        print "$totalLines\n";

This only limits me by the size of the file, or no?

Yes. If you have big files, replace the slurp with a loop.

--

Just my 0.00000002 million dollars worth,
   --- Shawn

"Probability is now one. Any problems that are left are your own."
   SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to