while ($x <= @array){ if ($array[$x] =~ m/$regex/){ splice @array, $x, 1; } }