http://www.perlmonks.org?node_id=1008468


in reply to How can one call the lowest value of an array by reference?

Here is one way:

#! perl use Modern::Perl; use List::Util qw( min ); my @vals = qw( 5 3 2 12 2 ); my @names = qw( Cat Bat Cow Dog Rat ); my $min_val = min @vals; my @indices = grep { $vals[$_] == $min_val } (0 .. $#vals); for (@indices) { printf "Lowest value: %d, index: %d, corresponding name: %s\n", $min_val, $_, $names[$_]; }

Output:

18:01 >perl 429_SoPW.pl Lowest value: 2, index: 2, corresponding name: Cow Lowest value: 2, index: 4, corresponding name: Rat 18:03 >

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,