反則ならこういうのもあるけど
f = open "xxx"
f.readlines
print f.lineno, "\n"

それでもperlより遅いのは何故だ。

perl>>458版
real 0m0.046s
user 0m0.040s
sys 0m0.000s

ruby反則版
real 0m0.054s
user 0m0.050s
sys 0m0.000s