my @numbers = (15,5,7,3,9,1,20,13,9,8, 15,16,2,6,12,90); printf ('The maximum number is %s%s', max(@numbers), "\n"); sub max { my $first = shift; while ($#_ >= 0) { # until list exhausted if ($first >= $_[0]) { # keep throwing away inferiors shift; } else { $first = shift; # crown the new king } } return $first; # end of list, inferiors exhausted }