in reply to Regex Find Words
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex Find Words
by ikegami (Patriarch) on Apr 29, 2010 at 18:44 UTC |