my @a_indices = (1,3,5); my @b = map {my $t = $_; (grep {$t == $_} @a_indices) ? undef : $t} 0 .. 9; print join ', ', grep {defined} @b;