Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: how to dereference for the following hash of hash of arrays

by pg (Canon)
on Nov 13, 2005 at 18:50 UTC ( [id://508127]=note: print w/replies, xml ) Need Help??


in reply to how to dereference for the following hash of hash of arrays

In this structure:

{ (name => "command1", id=> "001"), (name => "command2", id=> "002"), (name => "command3", id=> "003"), (name => "command4", id=> "004") }

You were deceived by the visual efforts. It looks like that all four name/id pairs were independent, but actually not. They were all at the same flat level - eight key/value pairs. There is no difference between your structure and the following:

{ name => "command1", id=> "001", name => "command2", id=> "002", name => "command3", id=> "003", name => "command4", id=> "004" }

Which hopefully helps you to see that, for example, name was assigned to some different values four times, and each time overwrites the previous one, thus it is left with the last assigned value "command4". So now we are saying that your original structure is the same as:

{ name => "command4", id=> "004" }

But the following structure is different, and all four pairs of name/id can coexist:

{ [name => "command1", id=> "001"], [name => "command2", id=> "002"], [name => "command3", id=> "003"], [name => "command4", id=> "004"] }

Replies are listed 'Best First'.
Re^2: how to dereference for the following hash of hash of arrays
by Tanktalus (Canon) on Nov 13, 2005 at 19:05 UTC

    pg, I don't think that does the trick either. See my response. Try dumping that structure ... you'll get something like this:

    $VAR1 = { 'component1' => { 'ARRAY(0x816936c)' => [ 'name', 'command4', 'id', '004' ], 'ARRAY(0x813bf00)' => [ 'name', 'command2', 'id', '002' ] }, # ...
    Not what you want at all.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-25 05:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found