http://www.perlmonks.org?node_id=790349


in reply to problem using foreach and each with hash ref

hi, I think it's not that much easy to both key and value pair for hash but you can get either key or value. In my code i used the keys indexes to get the values of hash reference.
use strict; use warnings; use Data::Dumper; my $hash_ref={1002=>[1,2,3,4,5],1001=>[6,7,8,9,10],3=>[2]}; my ($hashref,$array_ref,@array,); foreach $hashref( keys %$hash_ref){ $array_ref=$$hash_ref{$hashref}; @array=@$array_ref; print "Key = ".$hashref."\tValue = "; foreach (@array){ print "$_ \t"; } print "\n"; }