in reply to Loading a part of the file to array using Tie::File

++ on the previous answers. Note that your idea of first removing some lines by using other processes actually don't help, because tail has to read the file to count the lines anyway. perl might as well do it. And tail can read from a file directly, there's no need to first read it with cat and then pipe into tail. So your solution ended up being three processes, two of which would work on the whole file, instead of doing all that in one process.

Note that relying on the more common way to open a file will already handle memory pretty efficiently, by only keeping the current line, and current file cache in memory.

  • Comment on Re: Loading a part of the file to array using Tie::File