#! perl use strict; use warnings; my %hash = ( X => [ qw( A B ) ], Y => [ qw( C D E ) ], Z => [ qw( F G H ) ], ); for my $key (sort keys %hash) { my $array_ref = $hash{$key}; print "$_ $key, " for @$array_ref; } #### 14:29 >perl 737_SoPW.pl A X, B X, C Y, D Y, E Y, F Z, G Z, H Z, 14:29 >