There are many ways of doing this, and most of them are better, but this is pretty.
perl -le 'print $==()=<>' file [download]
In reply to Count the number of lines in a file by jmcnamara