John Doe wrote: > The Ghost am Freitag, 2. Dezember 2005 19.30: > >> 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";
You bring up an interesting point about closing the filehandle because normally you don't have to worry about that as perl will do the right thing. However in the example I posted using the $. variable: sub wanted { ... () = <FILE>; print "$.\n"; $totalLines += $.; } print "$totalLines\n"; Produces an incorrect value for $totalLines unless you close the filehandle but if you don't close the filehandle then you can do this: sub wanted { ... () = <FILE>; } print "$.\n"; 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>