in reply to (RhetTbull) Re: Looking for a better way to get the number of lines in a file...
in thread Looking for a better way to get the number of lines in a file...

Reading the file line-by-line is not going to be the most efficient way, esp. if the file is large. Instead you could read the file in blocks and count the newline characters

local $/=\102400; while(<FILE>) { $count += tr/\n// }

This example reads in chunks of 100K.

  • Comment on Re: Re: Looking for a better way to get the number of lines in a file...
  • Download Code