Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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.


Comment on Re: Tie a hash of hashes?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://527421]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2014-10-25 00:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (138 votes), past polls