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

Here's another option:

use Modern::Perl; my @values = qw/5 3 2 12 2/; my @names = qw/Cat Bat Cow Dog Rat/; my %hash; push @{ $hash{ $values[$_] } }, $_ for 0 .. $#values; my $lowest = ( sort { $a <=> $b } keys %hash )[0]; say "Positions of Lowest Value ($lowest) = @{$hash{$lowest}}"; print 'The animal names are: '; print join ' ', map $names[$_], @{$hash{$lowest}};

Output:

Positions of Lowest Value (2) = 2 4 The animal names are: Cow Rat

Replies are listed 'Best First'.
Re^2: How can one call the lowest value of an array by reference?
by supriyoch_2008 (Monk) on Dec 12, 2012 at 10:34 UTC

    Hi Kenosis,

    Thank you very much for your prompt reply and the code. It has worked well and has solved my problem.

    With Regards,