in reply to Memory use when reading a text file
This is related to your use of for(each), which tries to store the whole file in a temporary array in memory.
Try:
instead. This will simply copy each line into memory as needed.while( my $line = <INP> ){ ... }
In Section
Seekers of Perl Wisdom