http://www.perlmonks.org?node_id=508127


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"] }