in reply to TwoWay hash modification

You don't want a two-way hash, you want two hashes that are kept in sync:

my( %one, %two ); Tie::Hash::Complementary->marry( \%one, \%two ); $one{foo} = 'bar'; # Also sets $two{bar}= 'foo' $two{baz} = 'bif'; # Also sets $one{bif}= 'baz' $two{bar} = 'oof'; # Does: $one{oof} = delete $one{foo} $one{oof} = 'baz'; # Dies; $two{baz} can't be both oof and bif
Now you can go find or write Tie::Hash::Complementary.

Of course you can't have overlap between the keys with a single two-way hash. It is a single hash. You found a module that does something somewhat like what you want, but also fundamentally different than what you want.

                - tye

Replies are listed 'Best First'.
Re: Re: TwoWay hash modification (two hashes)
by shemp (Deacon) on Jun 25, 2003 at 19:22 UTC
    Tie::Hash::TwoWay does actually store the mapping in two different hashes internally, it just doesnt have any way to specify which direction to operate on, it tries the "primary" direction, and if the key doesnt exist, the operation is tried on the "secondary" direction.

    In any case, at lunch today, i designed a tie that does what i need, i'm about to implement it. I'll post about it, and submit it to CPAN, hopefully by the end of the day!