I'm planning on writing a simple text viewer, which I'd expect to be able to deal with very large sized files. I was thinking of using Tie::File
for this, and kind of paginate the lines. Is this loading the lines lazily, or all of them at once?
views:
69answers:
2
+7
A:
It won't load the whole file. From the documentation:
The file is not loaded into memory, so this will work even for gigantic files.
brunov
2009-12-03 20:44:12
but to find line 1830234, it has to read the entire file up to that point (though not all into memory)
ysth
2009-12-03 21:34:38
+6
A:
As far as I can see from its source code it stores only used lines in memory. And yes, it loads data only when needed.
You can limit amount of used memory with memory
parameter.
It also tracks offsets of all lines in the file to optimize disk access.
Ivan Nevostruev
2009-12-03 20:47:56