@array = grep !/$regex/, @array; #### $x = 0; while ($x < @array) { # NOT <=, but < if ($array[$x] =~ /$regex/) { splice @array, $x, 1 } else { ++$x } }