Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://527421]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2018-06-22 07:52 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (122 votes). Check out past polls.