in reply to Range check with unordered limits
But I find using explicit min and max adds more clarity, and newer Perls allow ternary° expressions "chained comparisons" a < x < b :
C:\tmp\e>perl use List::Util qw( min max ); ($a,$b) = (3,7); print "$_ is inside: ", min($a,$b) <= $_ <= max($a,$b),"\n" for 2..8 __END__ 2 is inside: 3 is inside: 1 4 is inside: 1 5 is inside: 1 6 is inside: 1 7 is inside: 1 8 is inside:
Using the spaceship that way is too clever for me.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
°) not sure if that's the right term
update: corrected. see perlop#precedence for more.
|
---|