wc -l file
From Perl you can read the file into an array, then use the array in scalar context to get the number of lines. Or, you could loop through and count, something like:
my $cnt;
open(FH,"file") or die "Damn. $!";
$cnt++ while <FH>;
close FH;
Or, use $. (perldoc perlvar)
while (<FH>) {}
print $.;
Or, to skip blank lines...
open(FH,"calendar.cgi") or die "Damn. $!";
while (<FH>) { $cnt++ if !/^\s+?$/;}
close FH;
Cheers,
KM
|