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


in reply to Re: Finding the max()/min()
in thread Finding the max()/min()

Here's another recursive form:

sub max { my( $i, @l ) = @_; my $j = @l ? max( @l ) : $i; return $i > $j ? $i : $j; }

And for that matter, an iterative form:

sub max { $_[ 0 ] < $_[ -1 ] ? shift : pop while @_ > 1; return @_; }

Makeshifts last the longest.