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)$/; }
In reply to Re^3: Sparing multiple 'or's
by hippo
in thread Sparing multiple 'or's
by Denis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |