There's a trick for jamming an expression into a string or regex:
my @result = "@input" =~ /@{[join "|", map "\\b$_\\b", @valuesToMatch]}/g;But you're probably better off using a hash for this. It'll be much faster if the arrays are large.
my %match; $match{$_} = 1 foreach @valuesToMatch; my @result = grep $match{$_}, @input;
In reply to Re: one line to check for common list values
by Anonymous Monk
in thread one line to check for common list values
by dollar_sign
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |