use List::Util qw( reduce ); sub min_idx { my ($ar) = @_; return reduce { $ar->[$b] > $ar->[$a] ? $b : $a } 0..$#$ar; }