my %cds = ( classical => [ [ 'Mozart', 'Requiem' ], [ 'Beethoven', '3rd Symphony' ] ], rock => [ [ 'Van Halen', '1984' ] ], jazz => [ [ 'Miles Davis', 'Birth of the Cool' ], [ 'Stan Getz', 'Brothers' ] ], ); for( sort keys %cds ) { print $_, ": ", scalar @{ $cds{$_} }, " in group\n"; for( @{ $cds{$_} } ) { print "\t", join(",", @{ $_ }), "\n"; } }