in reply to How can I find the index of the biggest element in an array?

my $max; my $index; my $x = 0; for ( @myarray ) { $index = $x and $max = $_ if !defined $max or $_ > $max; $x++; } print "The winner is element number $index: $myarray[$index]\n";

Replies are listed 'Best First'.
Re: Answer: How can I find the index of the biggest element in an array?
by I0 (Priest) on Mar 15, 2001 at 00:10 UTC
    There's still a bug, if the biggest element is at index 0