in reply to Slicing the output of a command

Just read as many lines as you need within a
while (<$fh>) {...
loop. Only one line at a time will be stored in memory.