in reply to TwoWay hash modification

I would suggest you just work directly with two hashes. Then you have full direct access to either hash as required, as it appears your problem requires you to distinguish them anyway.
$name{'555-1212'} = 'Jones'; $phone{'Jones'} = '555-1212';
I'm leery of modules which offer a bag of one-liner idioms, especially when it limits your control over the underlying native structures. Tie::File is cool as its implementation is non-trivial and subtle. Tie::Hash::TwoWay is not cool for the reason you found: it only works if you accept blanket assumptions.

--
[ e d @ h a l l e y . c c ]

Replies are listed 'Best First'.
Re: Re: TwoWay hash modification
by shemp (Deacon) on Jun 25, 2003 at 17:34 UTC
    Yeah, unfortunately, many modules are not very robust, in that they dont allow for much flexibility. But what can we expect for free! (we do get plenty).

    I want to have the operations encapsulated, otherwise, i'll need to perform operations on both hashes every time i want to do anything to one of them. So, i think im going to design my own variation, where you can specify in which direction the "key" operation should be dealt with. The interface may look something like:
    tie my %hash, 'Tie::Hash::MyTwoWay'; ... $hash->primary()->delete("foo"); $hash->secondary()->delete("foo");
    Here the 2 deletes perform VERY different operations, in that they delete from different directions.

    By default, an operation will take place on "primary"
    For enhancements, i'll probably add optional aliasing of "primary" and "secondary".