in reply to assigning the maximum of two numbers

sub assignmax5 { @a = sort@_; pop @a; }
I prefer this, especially for large arrays:
sub assignmax5 { return (sort @_)[-1]; }
It's immediately obvious, and easy to maintain.

Update: strike

-QM
--
Quantum Mechanics: The dreams stuff is made of

Replies are listed 'Best First'.
Re^2: assigning the maximum of two numbers
by Roy Johnson (Monsignor) on Nov 03, 2005 at 19:10 UTC
    But sort doesn't scale well, like List::Util 'max' does. So "especially for large arrays", you should not use sort to find the maximum.

    Caution: Contents may have been coded under pressure.
Re^2: assigning the maximum of two numbers
by Tanktalus (Canon) on Nov 03, 2005 at 19:25 UTC

    Especially for large arrays? Wouldn't this be an O(nlogn) function? I mean, if you wanted an arbitrary number of the maximum numbers in a list, sure, you're pretty much already sorting. But for just the top 1, you should use an O(n) algorithm, which gets even more important for "large arrays".

    For short arrays, the difference between sort and looping with a ternary will be minor. For long arrays, well, it becomes a bit more important.