in reply to Sparing multiple 'or's
TIMTOWTDI, but here are two methods (grep and regex) to get you started:
#!/usr/bin/env perl use strict; use warnings; my @cases = qw/ABA SCO ACC PHC GHF/; my $re = join '|', @cases; for my $text ('SCO', 'Microsoft') { print "$text found (grep)\n" if grep {$text eq $_} @cases; print "$text found (regex)\n" if $text =~ /^$re$/; }
PS. It would be better not to use $a as a variable name since that is special with respect to sorting.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sparing multiple 'or's
by AnomalousMonk (Archbishop) on Jun 04, 2018 at 16:28 UTC | |
by hippo (Archbishop) on Jun 04, 2018 at 21:02 UTC |