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

Trying to maintain parallel arrays in that fashion if fraught with peril. Instead use a data structure where you can treat each data pair as an entity. One way to do that would be to use OO and generate an object for each animal. For the current sample a simple hash will suffice. Consider:

use strict; use warnings; my %animals = ( Cat => 5, Bat => 3, Cow => 2, Dog => 12, Rat => 2 ); my %byValue; push @{$byValue{$animals{$_}}}, $_ for keys %animals; my @ordered = sort {$a <=> $b} keys %byValue; print "$_: @{$byValue{$_}}\n" for @ordered;


2: Rat Cow 3: Bat 5: Cat 12: Dog

Note the use of the reverse lookup hash byValue to ease accessing the animals in sorted order.

True laziness is hard work