in reply to Re^2: my 'if' condition doesn't work, why?
in thread my 'if' condition doesn't work, why?
shame that it's not standard Perl but instead requires an extra module
Well, you can get a similar result using List::Util, which is a core module:
#! perl use strict; use warnings; use List::Util 'any'; for my $n (0 .. 267) { print "$n\n" if any { $n == $_ } (40, 47, 76); }
Update: Fixed off-by-one error in the for loop range, thanks to AnomalousMonk.
Output:
17:34 >perl 1074_SoPW.pl 40 47 76 17:34 >
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|