foreach my $hash (@a){ foreach my $key (keys %{$hash}){ print "key >$key< value>",$hash->{$key},"<\n"; } } #### use strict; use warnings; use diagnostics; #### $a[$j]{$key} and $a[$j]->{$key} both will work #### for my $key (keys %{$a[0]}) according to your above presented logic #### before calling the second for loop just try use Data::Dumper; print Dumper \@a;