in reply to Re: Sparing multiple 'or's
in thread Sparing multiple 'or's
++ For the hash method, although your nested structure makes it look more complex than the other solutions. It can be made to look much simpler using a single level, and the fact that there won't be autovivification in boolean context:
# equivalent to %is_valid = (ABA => 1, SCO => 1, ACC => 1...); my %is_valid = map { $_ => 1 } qw( ABA SCO ACC PHC GHF ); if ($is_valid{$variable}) # Easy to read { ... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Sparing multiple 'or's
by Tux (Canon) on Jun 04, 2018 at 19:23 UTC | |
by Eily (Monsignor) on Jun 05, 2018 at 08:55 UTC |