The Ghost am Freitag, 2. Dezember 2005 19.30:

Hi,

In addition to John W. Krahn's good advices:

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

Always check if operations succeeded:

   open (FILE, '<', $File::Find::name) 
      or die "couldn't open $File::Find::name: $!";

>        print "$_: ";
>       my @lines=<FILE>;

and close opened files:

        close FILE or die "couldn't close $File::Find::name: $!";

>       print "$#lines\n";
>           $totalLines+=$#lines; #wanted's value is ignored so we have to
> do this here.
>       return;}
>           print "$totalLines\n";
>
> This only limits me by the size of the file, or no?
>
> Thanks!

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