in reply to Count number of lines in a text file
while (sysread FILE, $buffer, 4096) { $lines += ($buffer =~ tr/\n//); } [download]
Use:
while (<FILE>) { $lines++ } [download]