When I run your code, it seems to work as expected:
HoA test 1: ARRAY(0x8111b78) HoA test 1: aaa HoA test 1: 3
You are, respectively, printing the array reference itself, the first element of the array and the array in scalar context, which produces the number of elements in the array.

FYI, here are some general ways of manipulating HoA's:

# Initialisation my %HoA = ( 'camel' => [ 'flea', 'bug-ridden', 'brown' ], 'flea' => [ 'camel-loving', 'bug', 'too tiny to tell' ] ); # Adding arrays: $HoA{'frog'}= [ 'tadpole', 'no bugs', 'green' ]; # Getting element of an array print "A camel is: ".$HoA{'camel'}->[2];
A very useful module in this regard is Data::Dumper. You can use it to inspect the structure of your HoA:
# HoA from above use Data::Dumper; print Dumper(\%HoA);
Results in:
$VAR1 = { 'flea' => [ 'camel-loving', 'bug', 'too tiny to tell' ], 'camel' => [ 'flea', 'bug-ridden', 'brown' ], 'frog' => [ 'tadpole', 'no bugs', 'green' ] };
For more information, I recommend perldata, perlref and perldsc, all included in the standard Perl distribution.

CU
Robartes-


In reply to Re: Hash of Arrays by robartes
in thread Hash of Arrays by Lhamo Latso

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.