in reply to Going through a big file [solved]
> First I tried the obvious
open in, shift @ARGV; for(<in>){
Obvious?
You will hardly find any example in the perldocs ever trying this.
Rather
open in, shift @ARGV; while (<in>){
or better
open my $in, '<', shift @ARGV; while (my $line = <$in>){
Explanation
your code is semantically equivalent to
slurping the whole file as a first step.my @temp_list=<in>; for(@temp_list){
for expects a list and evaluates in list context¹, so it's greedily swallowing all at once.
But while iterates in scalar context, that is line by line (as defined by '$/')
Cheers Rolf
¹) with a little magical exception in recent Perl versions (>= 5.8 ?) regarding ranges, which isn't relevant here
In Section
Seekers of Perl Wisdom