in reply to one line to check for common list values
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;
|
|---|