The Ghost wrote:
> So far I did this:
> 
> #!/usr/bin/perl

That should be followed by these two lines:

use warnings;
use strict;


> use File::Find;
> my $totalLines;
>     find(\&wanted, '@directories');

Do you actually have a directory in the current directory named '@directories'?


>     sub wanted {
>      unless ($_=~m/.html|.mas|.pl|.txt$/i) {return 0;} #filter the

Your regular expression says to match any character (.) followed by the string
'html' anywhere in $_ OR any character followed by the string 'mas' anywhere
in $_ OR any character followed by the string 'pl' anywhere in $_ OR any
character followed by the string 'txt' only at the end of $_.  What you
probably what is:

        return unless /\.(?:html|mas|pl|txt)$/i;


> 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 

$#lines is one less then the number of lines in the file so your total will
not be accurate.  That should be:

        $totalLines += @lines;

But you don't really need to store all the lines in an array, you can do it
more simply as:

        () = <FILE>;
        print "$.\n";
        $totalLines += $.;

Or use the example in the FAQ:

perldoc -q "How do I count the number of lines in a file"


> do this here.
>         return;}
>         print "$totalLines\n";
> 
> This only limits me by the size of the file, or no?


John
-- 
use Perl;
program
fulfillment

-- 
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