in reply to How to make sure no elements from @array are inside $scalar

Hi,

IMHO it's ok. I have three annotations:

If the array referred by $sites is used more than once, you could think about concatenating '_9' before doing the match.

You want to delete the item as soon as one pattern matches. Therefore you can shortcut the grep with using List::Util::any.

You could try to match against a regex which is build from the elements of the list.

my $regex = '_9(?:' . join('|', map { quotemeta } @$sites) . ')'; $text =~ /$regex/;

Regards
McA