my %hash = ( one => [ 1, 2, 3, ], two => [ 4, 5, 6, 7, ], three => [ 8, ], ); print ((join "\t", (sort keys %hash)),"\n"); my $i = 0; my $defined; do { $defined = 0; map {$defined++ if defined $hash{$_}->[$i]} (keys %hash); for (sort keys %hash) { print $hash{$_}->[$i] // " ", "\t"; }; print "\n"; $i++; } while ($defined > 0); __END__ one three two 1 8 4 2 5 3 6 7