in reply to Mathching an array in regex

There have been concise explanations for the
behavior you found.

I'd use a core module (List::Util) for that:
use List::Util qw(first); my @arr=('cool','guy','here'); my $str1="I am cool"; my $hit = first{ $str1 =~ /\Q$_/ } @arr; print "Matched $hit";
Regards

mwa