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.HoA test 1: ARRAY(0x8111b78) HoA test 1: aaa HoA test 1: 3
FYI, here are some general ways of manipulating HoA's:
A very useful module in this regard is Data::Dumper. You can use it to inspect the structure of your HoA:# 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];
Results in:# HoA from above use Data::Dumper; print Dumper(\%HoA);
For more information, I recommend perldata, perlref and perldsc, all included in the standard Perl distribution.$VAR1 = { 'flea' => [ 'camel-loving', 'bug', 'too tiny to tell' ], 'camel' => [ 'flea', 'bug-ridden', 'brown' ], 'frog' => [ 'tadpole', 'no bugs', 'green' ] };
CU
Robartes-
In reply to Re: Hash of Arrays
by robartes
in thread Hash of Arrays
by Lhamo Latso
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |