in reply to
what's this loo code?
I waited and two explanations have already appeared as I hoped and expected...
But I wanted to mention my first impression when I saw that code in jmcnamara's node: "Oh, that takes way too much memory and will fail for files that don't fit within your available swap space".
The number of possible Perl one-liners that print a line count and don't suffer from requiring way too much memory for large files is quite huge. I'll shoot for a very straight-forward one:
perl -le '1 while <>; print $.' file
I'm almost certain you can make that faster or shorter (without reintroducing the memory hog aspect of it), but I really don't care to do either.