for my $key ( sort {length($b) <=> length($a)} keys %hash ) { my $value = $hash{$key}; print "$key => $value\n"; }