for my $i (0..$max_hash_key) { print defined $hash{$i} ? "$hash{$i}\n" : "\n"; }