Count the number of lines in a file without actually iterating through the file

From: Jason Normandin (jason_normandin_at_charter.net)
Date: 02/26/04


To: "Perl Beginners" <beginners@perl.org>
Date: Wed, 25 Feb 2004 18:55:46 -0500

Hi List.

 

Is there a way to determine the number of lines in a file without actually
iterating through the file and incrementing a file?

 

I found the following on perlmonks.org, it works great but this is command
line syntax

:

perl -lpe '}{*_=*.}{' file

 

How could I integrate this into a script without invoking another instance
of Perl?

 

Thanks !

~Jason

------------------------------------

 

 "If, after the first twenty minutes, you don't know who the sucker at the
table is, it's you."

 

------------------------------------