#!/usr/bin/perl use strict; use warnings; my %hash = ( key1 => ['dies'], ist => ['ein'], Test => ['hallo'], was => ['wert'], los => ['hash'], ); for my $k (sort { $hash{$a}->[0] cmp $hash{$b}->[0] or $a cmp $b } keys %hash) { my @arr = grep { defined $_ } @{ $hash{$k} }; if (@arr) { printf "%-25s : %-80s\n", $k, "@arr"; } }