my @a_indices = (1,3,5); my %hasIndex = map {$_ => undef} @a_indices; my @b = map {exists $hasIndex{$_} ? undef : $_} 0 .. 9;