in reply to min and mindex

#!/opt/local/bin/perl use strict; use warnings; use List::MoreUtils qw(firstidx minmax); my @array1 = qw(9 8 7 1 2 3 4 5 6 7); my @array2 = qw(i h g a b c d e f g); my $min = (minmax @array1)[0]; my $mindex = firstidx { $_ eq $min } @array1; print "min = $min, mindex = $mindex, array2[$mindex] = $array2[$mindex +]\n";

This does scan @array1 twice, but that will not be an issue for small arrays, and if you are using the XS version of List::MoreUtils, this implementation may still be faster than rolling your own min/mindex code.