my @a_indices = (1,3,5); my @b = map {my $t = $_; (grep {$t == $_} @a_indices) ? undef : $t} 0 .. 9; print join ', ', grep {defined} @b; #### 0, 2, 4, 6, 7, 8, 9 #### my @a_indices = (1,3,5); my %hasIndex = map {$_ => undef} @a_indices; my @b = map {exists $hasIndex{$_} ? undef : $_} 0 .. 9;