in reply to out of memory error while reading file contents into an array

Please read Markup in the Monastery; in particular, please do not use <pre> tags in your write-ups, as they screw up many people's display and generally make grumpy monks.

If you don't have space to hold the entire file in memory, then don't read in the entire file - process line by line.

open (IN, filename) or die "cann't open file filename : $!\n"; while (defined(my $line = <IN>)) { #process $line } close (IN);

Replies are listed 'Best First'.
Re^2: out of memory error while reading file contents into an array
by psr473 (Novice) on Aug 12, 2009 at 11:41 UTC

    Thanks for your help. I will try line by line.