in reply to Re^2: getting the highest value in a simpler way
in thread getting the highest value in a simpler way
[ $x => $y ] is the same as [ $x, $y ] which is the essentially the same as
my $ary = ( $x, $y ); my $aryRef = \ @ary;
And $x <= $y is just a boolean expression that will give a false (0) result if $x > $y and true value (1) otherwise.
$aryRef->[ 0/1 ] will return either $ary[ 0 ] or $ary[ 1 ].
Putting it all together, you get an expression that will construct an anonymous array containing $x, $y, then dereferences that anonmous array and uses the boolean result of the comparison to select the greater of the two values before assigning it to the scalar.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: getting the highest value in a simpler way
by uksza (Canon) on Dec 19, 2004 at 15:34 UTC |