%hash = ( hash1 => [sort keys %hashInArry1], hash2 => [sort keys %hashInArry2], ); foreach my $key (keys %hash) { print "$key: ", join(", ", @{$hash{$key}}), "\n"; }