Jason Normandin wrote:
> 
> Hi List.

Hello,

> 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

Ooh, an obfuscated verbose way of writing:

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


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

open FILE, 'somefile' or die "Cannot open somefile: $!";
1 while <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>


Reply via email to