unlox775_0 has asked for the wisdom of the Perl Monks concerning the following question:

I've made this library, called Tie::MorphHash, to use @ISA polymorphism on package global hashes (of hashes, etc) using tie(). It works great until you have 3 levels of @ISA inheritance. At that point, this breaks:
use Data::Dumper qw(Dumper); print Dumper $cc::zz{key1}{subkey1};
but this doesn't:
use Data::Dumper qw(Dumper); my $key1 = $cc::zz{key1}; print Dumper $key1->{subkey1};
I've boiled the problem down as much as I can. To get the whole source for the example, download:

http://unlox775.8m.com/morphhash_error.tgz

This is quite a doosey to debug. I've left a buncha debug in the Tie::MorphHash library, you just need to set $Tie::MorphHash::debug to 1 and it will tell you about All Tiehash related events and details. It's pretty verbose...

Thank you, Thank you, Thank you if you can figure out a decent way around this!

Replies are listed 'Best First'.
(tye)Re: Recursive tied hash crap out
by tye (Sage) on Nov 29, 2001 at 03:49 UTC

    That link you gave results in "permission denied".

    Be sure not to access a tied variable from inside of a FETCH routine. To work around that bug, instead of:

    sub FETCH { # ... $val= $refToTiedHash->{$key}; # ... }
    use
    sub FETCH { # ... $val= tied(%$refToTiedHash)->FETCH($key); # ... }
    for example.

            - tye (but my friends call me "Tye")