my @array; $array[3] = 2; for my $i (0..5) { say $i . ": " . (exists $array[$i]); }