Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Tie a hash of hashes?

by ikegami (Pope)
on Feb 02, 2006 at 20:24 UTC ( #527421=note: print w/replies, xml ) Need Help??

in reply to Tie a hash of hashes?

The problem:

You need to convert the hashes into Tie::IxHashes.

Solution 1:

You could traverse %data and convert the appropriate hashes.

Solution 2:

You could create a subclass of Tie::IxHash to override its method. When a hash reference is added to the hash, tie the referenced hash if it isn't already tied. Don't forget to untie when appropriate.

Update: Time for a break! Neither solution works, because the order is already lost by the time the hashes can be converted.

What you need to do is to override the behaviour of the hash constructor { ... } at compile time, and I don't see any simple ways of doing that. The complex ways are 1) use a source filter and 2) replace the Perl compiler by parsing the file yourself.