Hello Perl Monks:

I want to print an array of 20 hashes. Each hash has 2 types of keys.

I am not too particular about how to print. I am just doing this to check that the array has all 20 hashes working, where the correct value is associated with the correct two keys. One way I might like to check the array (if possible) is to print the values from each hash of the array (That is, check that hash1 has the correct values with the correct key1s and key2s, then check that hash2 has the correct values with the correct key1s and key2s, ....).

This is the general idea of my code. The values of all hashes are all strings or empty strings.

sub getArrayHash{ $hash1s->{$key1}->{$key2} = $hash1; $hash2s->{$key1}->{$key2} = $hash2; $hash3s->{$key1}->{$key2} = $hash3; . . . $hash20s->{$key1}->{$key2} = $hash20; push( @hash_array, $hash1s, $hash2s, $hash3s, ..., $hash20s); return \@hash_array; }

So, any ideas on how to check that my hash_array has the correct values? Thank you in advance!


In reply to Array of Hashes by SuzuBell

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.