opening a file in perl

Nemo - earth native nemo at cheeky.house.cx
Wed May 1 09:58:12 EST 2002


Hi guys, a quick question for the perl guru's around... 

I've a small script which opens a file, reads through it looking for
various information, uses that to calculate some figures, and closes.

Pretty simple stuff. 

...except when the file being opened is the better part of 400meg,
and so I get Out of Memory errors - the perl seems to wants to read the
whole file into memory before looking at it at all.

At the moment is opens the file as such:
	open( IN, "chunk.txt" ) or die "Hrm. Couldn't open the file./n";

And then just runs through line by line:
	foreach my $line ( <IN> )
	{
(insert a few possible regexp matches in `if` statements here. simple stuff)
	}

So, how do you get perl to not load the whole file into memory?

.../Nemo







More information about the linux mailing list