use strict; use warnings; use Data::Dumper;; my %hash = ( A => [1,2], B => [4,6], ); # just to see what we have print Dumper \%hash; # and this prints what you want (i think) print "$_ => @{ $hash{$_} }\n" for sort keys %hash;