my @tmp; for my $item (@T) { if (..insert condition..) { push @tmp, 'Scooby Doo!'; } if (..keep condition..) { push @tmp, $item; } } @T = @tmp;