in reply to not able to get last index of array

If you only want the maximum value, you don't need to sort, e.g.:
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 }

One world, one people

Replies are listed 'Best First'.
Re^2: not able to get last index of array
by hippo (Archbishop) on Jun 02, 2016 at 12:46 UTC

    Quite. It's even simpler if you know that List::Util has been in core for the last decade and has its own max() function.