I have written a class to provide a multi-key hash via tie(). It has 
some differences with Tie::ListKeyedHash. This is an overview of how it 
works:

    tie %hmk, 'Hash::MultiKey';

    $keys1 = [ qw(foo bar) ];
    $hmk{ $keys1 } = 1;

    $keys2 = [ qw(foo bar baz) ];
    $hmk{ $keys2 } = { zoo => 'this works' };
    exists $hmk{ [ @$keys2, 'zoo' ] }; # false, hashrefs do NOT nest
    ref $hmk{ $keys2 } eq 'HASH'; # true

    $keys1_clone = [ @$keys1 ];

    $hmk{ $keys1_clone } = undef;
    exists $hmk{ $keys1 }; # true, key-chains by value, and
                           # standard exists() behaviour

    exists $hml{ ['foo'] }; # false, just whole key-chains, as they
                            # were given

    # etc.

There is basically a tree behind the scenes.

This would be my first public module, but I am following Sam Tregar's 
recommendations from his book for this, so the distribution itself will 
be pretty standard. (Wonderful book, thank you!)

The module needs yet some testing, but it's time to run h2xs and work 
with a true skeleton now. Is that name OK? Would 'Hash::MultiKeyed' be 
more correct in English? Should it have to live under Tie:: instead?

Any comments would be very much appreciated.

Best regards from template Barcelona,

-- fxn

Reply via email to