my $max = 0; for (1 .. $#data) { $max = $_ if $data[$_] > $data[$max] }