c:\@Work\Perl\monks>perl -wMstrict -le "my @cases = qw/ABA SCO ACC PHC GHF/; my $re = join '|', @cases; ;; for my $text ('SCO', 'ENDOSCOPE', 'Microsoft') { print qq{'$text' found (grep)} if grep { $text eq $_ } @cases; print qq{'$text' found (regex)} if $text =~ /^$re$/; } " 'SCO' found (grep) 'SCO' found (regex) 'ENDOSCOPE' found (regex)