use strict; use warnings; use Test::More; my @stopwords = qw/foo sous bar/; my ($rx) = map qr/(?:$_)/, join "|", map qr/\b\Q$_\E\b(?!-)/, @stopwords; my @stop = ( 'foo is good', 'so is sous' ); my @go = ( 'sous-alimentation', ); plan tests => @stop + @go; for my $str (@stop) { like ($str, $rx, "$str matched"); } for my $str (@go) { unlike ($str, $rx, "$str not matched"); }