The Goatse operator, of course!
my $left_text = [ qw{ when rome romans} ]; my $right_text = 'When in Rome, do as the Romans.'; my $regex = join "|", @$left_text; my $found =()= $right_text =~ m/($regex)/ig; print "$found\n";
You're forcing the list of captures into scalar context.
Edit: Thanks for the ++, but AnomalousMonk and moritz posted the same solution earlier than I did. I just added that it had a name.
In reply to Re: Regex Find Words
by AR
in thread Regex Find Words
by Xiong
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |