perlquestion
Angharad
Hi there
<br>
I'm wanting to store the contents of a particularly large text file into a hash so I can use it as a look up table later on in the perl script. I've written the code to create the hash, but the act of storing the data is taking an impossibly long time. Heres the code:
<code>
use strict;
use Data::Dumper;
my $file = shift;
my %hash;
open(IN, "$file") || die "ERROR: can't open $file: $!\n";
while(<IN>)
{
chomp;
my @info = split(/\,/, $_);
my $md5 = $info[0]; # I only want to store the data
# in columns 1 and 2
my $uni = $info[1];
$hash{$uni} = $md5;
}
close IN;
</code>
Can anyone tell me a better way of doing this so that the contents of the file are stord in the hash more quickly? Any thoughts much appreciated!!