http://www.perlmonks.org?node_id=1137988


in reply to Ternary vs. Sort vs. Max

I personally prefer the ternary as it involves no overhead of extra scopes, loading modules and/or function calls: it is fast, obvious and clear (at least if you are acquainted with ternary syntax).

Your worry about duplicating the value is only important if the implementation of ternary is such that it actually invokes the FETCH on the variable twice (in any language), which can be problematic is the value is overloaded and does magic on fetch.

Calling sort could suffer the same, depending on the implementation.


Enjoy, Have FUN! H.Merijn