in reply to Conditional Elimination
If you have a long list of items to check $p against, you could try something like
my @ptests = (88,89,90,91,110,115); if ( grep {$p == $_} @ptests ) { return $p; }
Then it's easy to add new items to the list and the code does not need to change.
or you could use List::MoreUtils firstval which may be slightly more efficient if you have long lists
use List::MoreUtils qw {firstval}; my @ptests = (88,89,90,91,110,115); if ( firstval {$p == $_} @ptests) { return $p; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Conditional Elimination
by Kc12349 (Monk) on Aug 31, 2011 at 22:19 UTC |