Don't ask to ask, just ask | |
PerlMonks |
Re: How To Count Lines In File?by jmcnamara (Monsignor) |
on Jan 27, 2003 at 00:00 UTC ( [id://230081]=note: print w/replies, xml ) | Need Help?? |
The FAQ method is more efficient because it is reading in fixed block sizes which it doesn't have to split into lines. Here is a benchmark to show the difference. I added wc for comparison:
Here is the way I usually don't do it, this is twice as slow as the slowest method above: perl -le 'print $==()=<>' file
--
In Section
Seekers of Perl Wisdom
|
|