for my $string (@array) { my $x = $string =~ s{ /\* .* }{}x .. $string =~ s{ .* \*/ }{}x; if (not $x or $x < 2 or $x =~ m/E0$/) { push @new, $string; } }