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

In reply to Re: how to dereference for the following hash of hash of arrays by pg
in thread how to dereference for the following hash of hash of arrays by srins

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.