The "values" are array references so you have to dereference them using @{ ... } to get the array elements. You can also get there using keys and dereferencing the looked up value in the hash.
knoppix@Microknoppix:~$ perl -MData::Dumper -Mstrict -wE '
> my @aTags = ( 1 .. 4 );
> my @bTags = reverse 6 .. 9;
> my %alpha = ( a => \ @aTags, b => \ @bTags );
> print Data::Dumper->Dumpxs( [ \ %alpha ], [ qw{ *alpha } ] );
> say q{-} x 20;
> say qq{@{ $_ }} for values %alpha;
> say q{-} x 20;
> say qq{@{ $alpha{ $_ } }} for keys %alpha;
> say q{-} x 20;
> foreach my $arrayRef ( values %alpha )
> {
> say for @{ $arrayRef };
> say q{-} x 20;
> }
> foreach my $key ( keys %alpha )
> {
> say for @{ $alpha{ $key } };
> say q{-} x 20;
> }'
%alpha = (
'a' => [
1,
2,
3,
4
],
'b' => [
9,
8,
7,
6
]
);
--------------------
1 2 3 4
9 8 7 6
--------------------
1 2 3 4
9 8 7 6
--------------------
1
2
3
4
--------------------
9
8
7
6
--------------------
1
2
3
4
--------------------
9
8
7
6
--------------------
knoppix@Microknoppix:~$
I hope this is helpful.
Update: Expanded the example code to show how to print one element per line as the OP's code seemed to want.
|