I also seriously question the wisdom, and the necessity, of buffering “from 1K to 1 million lines” in memory. “Why is {the virtual} memory {paging file} superior to the file that you are already reading?” Also: is this logfile a file of a well-known format, such as an Apache server log, for which a suitable CPAN module already exists? Might you, quite without intending to do so, be “doing a thing already done?” Aye, ’tis dreadfully easy to do...