in reply to Re^2: file size limit with Tie::File
in thread file size limit with Tie::File
Unfortunately expecting to get the number of lines in a text file without reading the file is an impossibility no matter what module you use. Lines in a plain text file are of variable length. So there is no simple calculation that if a file is xxx kilobytes it must be yyy lines long. That means the only way for any program or module to determine how many lines you have, is to count how many "newline" characters are found in the file. And that's the same as counting any other character; you've got to read through the file to find out.
Quick, how many lines are there in the camel book? Until you've counted them, you'll never know. There's no magic here. If you need a quick solution, do a line count once and save it, and modify it as the file gets modified.
Tie::File is a convenience module, and it provides this convenience with what seems usually to be a very minor performance penalty. You have stumbled into a situation where the module doesn't appear to excel, but regardless of the solution you come up with, you're going to have to read the file at least once.
Dave
|
|---|