Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

two ways hash

3 views
Skip to first unread message

news forthnet

unread,
May 14, 2009, 9:33:58 AM5/14/09
to
Hello, I need quick access of a 2 column data on both ways. The following
code is doing the job, but the problem is that the file I am reading is over
than 500Mb and I loose 4 times this size of my physical memory . Is there
any way to keep less columns in memory ( ideal 2 ) without loosing the "two
ways" functionality ?

my %Forward;
my %Reverse;
while (<DATA>){
/^\s*(.*?)\|(.*?)\s*$/;
$Forward{$1}=$2;
$Reverse{$2}=$1}
print "$Forward{KEY5} $Reverse{VALUE0} \n";

__DATA__
KEY0|VALUE0
KEY1|VALUE1
KEY2|VALUE2


Gunnar Hjalmarsson

unread,
May 14, 2009, 9:47:59 AM5/14/09
to

That's what databases are for. The best way would be to store the data
in e.g. a MySQL database. If that's not feasible, maybe a couple of DBM
databases might be useful.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

0 new messages