This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.
To: sfpug@sf.pm.org
From: Nicolai Rosen <nick@netaxs.com>
Subject: [sf-perl] Referential Hashes
Date: Thu, 14 Sep 2000 19:45:43 -0400 (EDT)
I'm trying to create a hash of references to the values of another
hash. It works until I tie the hash of references to a database. Any way
around this? Here's my code. It works if I comment out the 2nd tie:
my( %db1, %db2 );
$DB_BTREE->{'flags'} = R_DUP;
tie %db1, 'DB_File', "db1.db";
tie %db2, 'DB_File', "db2.db", O_CREAT | O_RDWR, 0666, $DB_BTREE;
$db1{ "blah" } = "5 is a number I like";
$db2{ "5" } = \$db1{ "blah" };
print ${ $db2{ "5" } };
untie %db1;
untie %db2;
===
To: sfpug@sf.pm.org
From: Nicolai Rosen <nick@netaxs.com>
Subject: Re: [sf-perl] Referential Hashes
Date: Thu, 14 Sep 2000 21:17:55 -0400 (EDT)
On Thu, 14 Sep 2000, Austin S. Lin wrote:
> you probably need MLDBM to preserve the inner references:
>
> perldoc MLDBM
It's still not working:
Can't use string ("SCALAR(0x133cc4)") as a SCALAR ref while "strict
refs" in use at ./books.pm line 24.
I think the problem is that the references to %db1 should be different
each time the program's activated, whilst %db2 is trying to leave them
constant.
===
To: sfpug@sf.pm.org
From: Nicolai Rosen <nick@netaxs.com>
Subject: Re: [sf-perl] Referential Hashes
Date: Thu, 14 Sep 2000 21:45:21 -0400 (EDT)
On Thu, 14 Sep 2000, Nicolai Rosen wrote:
> On Thu, 14 Sep 2000, Austin S. Lin wrote:
> > you probably need MLDBM to preserve the inner references:
> >
> > perldoc MLDBM
> It's still not working:
> Can't use string ("SCALAR(0x133cc4)") as a SCALAR ref while "strict
> refs" in use at ./books.pm line 24.
>
> I think the problem is that the references to %db1 should be different
> each time the program's activated, whilst %db2 is trying to leave them
> constant.
Ack, nevermind. I didn't fully convert over my code.
On a related note though, does MLDBM not support duplicate hash entries or
did I miss something?
===