Fascinating how most replyers misunderstood you're question, cause they read the title but not the code.
I fail to see how explanations that you can only store scalars (such as references, but not hashes) in an array imply a misunderstanding of the questions asked in the OP, which, for reference, are: "I'd like to know how to do that without using references?" and "How can I do the same code the same thing without using references?"

You need to write %rec=() because you don't want references.
...and that still won't work, because the code ultimately does a push @AoH, $rec; Changing $rec to %rec will just plain not work because, even without strict, $rec and %rec are two different variables with no direct connection between them, so it would just be pushing an undef into @AoH.

Of course, that could easily be fixed by changing the push to push @AoH, %rec;, which will work... but it will do something completely different than what the OP wants, as explained in b4swine's answer.

Guess you misunderstood the question because you started reading the code, then addressed the first problem you saw without bothering to read all the code.

The answer to the question actually asked, as previous posters have correctly understood, is "You can't do that without using references."


In reply to Re^2: Generate Array of Hashes WITHOUT References by dsheroh
in thread Generate Array of Hashes WITHOUT References by tel2

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.