|
|
| Just another Perl shrine | |
| PerlMonks |
How to tie multilevel (multidimensional) hash?by mikezone (Novice) |
| on Feb 11, 2003 at 23:12 UTC ( #234549=perlquestion: print w/ replies, xml ) | Need Help?? |
|
mikezone has asked for the
wisdom of the Perl Monks concerning the following question:
Hello wise monks, I'd like to have some syntactical sugar to wrap a datastructure that I have. What I'd like to do is say: and have custom behaviour, based on the values of 'x', 'y', and 'z', and the dimension specified. In other words, if FETCH and STORE took multiple arguments for keys (along the lines of the following:) then I'd just write my code in the MultiHash::STORE and ::FETCH methods and be very happy. But these methods don't work that way. So far, I've tried recursively nesting tied hashes (but that didn't work; the recursive FETCH call apparently received no argument for $key). I've looked at Tie::MLDBM and Tie::RefHash for possible insight but I didn't learn much, and both searching Google and the PerlMonks archive hasn't helped me. How can I get around this problem? Thanks in advance,
Back to
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||