in reply to Re^2: Sparing multiple 'or's
in thread Sparing multiple 'or's

Good catch (++). As dave_the_m suggested we can use brackets in this case:

#!/usr/bin/env perl use strict; use warnings; use utf8; my @cases = qw/ABA SCO ACC PHC GHF/; my $re = join '|', @cases; for my $text ('SCO', 'ENDOSCOPE', 'Microsoft') { print "$text found (grep)\n" if grep {$text eq $_} @cases; print "$text found (regex)\n" if $text =~ /^($re)$/; }