#!/usr/bin/perl
use warnings;
## To find lowest value and to call by reference:
@values=qw/5 3 2 12 2/;
@names=qw/Cat Bat Cow Dog Rat/;
# To find the lowest value from the array A:
$min=999;
foreach my $item (@values) {$min=$item if $min > $item;}
print"\n\n Lowest value= $min\n";
# To find the position of LOWEST Value(2) in Array values:
@array_element_pos{@values}=(0..$#values);
$i=$array_element_pos{$min};
print"\n Positions of Lowest Value(2)= $i (should be 2 & 4)\n";
# To extract corresponding animal name from Array names:
print"\n The animal names are (should be Cow & Rat): ".$names[$i]."\n";
exit;
####
C:\Users\x>cd desktop
C:\Users\x\Desktop>key1.pl
Lowest value= 2
Positions of Lowest Value(2)= 4 (should be 2 & 4)
The animal names are (should be Cow & Rat): Rat
####
Lowest value= 2
Positions of Lowest Value(2)= 2 4 (should be 2 & 4)
The animal names are (should be Cow & Rat): Cow Rat