in reply to tieing HoH
When you execute the statement $hash{toby}{ip} = '111'; on a newly created (and tied) hash, you are asking perl to
The actual sequence perl performs thise steps is probably different, but they must all be performed.
In other words, the assignment $hash{toby}{id} = '111'; isn't an assignment to the hash %hash;
It is an assignment to the key 'id', within the anonymous hash that is the value of the key 'toby' within the hash %hash.
As %hash is newly created and the key 'toby' does not exist, perl has to 'autovivify' (ie. create) the key 'toby' and assign an anonymous hash to it, before it can create the 'id' key and assign '111' to it.
Not sure if that clarifies anything?
The short answer to "Could this be problem 'cause it is not one-level-hash..", is Yes!.
If you want to tie a multilevel hash, you would have to inspect the values STOREd into your base-level hash, and if they are hash references, tie these also. This is non-trivial to get right.
Hope that help is some way:)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: tieing HoH
by bugsbunny (Scribe) on Jan 14, 2004 at 15:14 UTC |