Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I apologize if this is an utterly clueless question, but I'm a newbie so here goes:
All I want to do is to be able to correlate two entries in a very large text file, for instance the file is of the format:
12 4433 13 4433 14 4476 15 4477 16 4477
...and so on with tabs separating the columns. I'm going to be accessing this array hundreds of thousands of times. Now the approach for this that seemed obvious to me was just like this:
while (chomp($input=$handle->getline)) { @temp=split("\t",$input); $index[$temp[0]]=$temp[1]; }
Which is great, now we have $index(field 1 value) = field 2 value, which is what I wanted. and works great for the original 40 meg text file.
The problem comes with the new text file, which is almost 400 megs (many millions of entries). My system slows to a crawl and eventually seizes up. I assume this is most likely memory issues (only 256M physical due to a RAM blowout, another 500 M swap) or something, but I'm not sure.
Is there a better way to do this kind of thing for a huge text file like this?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Very large text file - simple indexing
by zby (Vicar) on Apr 09, 2003 at 20:13 UTC | |
by diotalevi (Canon) on Apr 09, 2003 at 20:43 UTC | |
Re: Very large text file - simple indexing
by BrowserUk (Patriarch) on Apr 09, 2003 at 20:52 UTC | |
Re: Very large text file - simple indexing
by waxmop (Beadle) on Apr 09, 2003 at 20:06 UTC | |
Re: Very large text file - simple indexing (seek)
by tye (Sage) on Apr 10, 2003 at 16:31 UTC |