in reply to Returning the lowest key in a hash (or highest)

Perl does not solve this problem particularly cleanly, but it can be arranged to.

Since Perl is list-oriented, a design that allows you to think in terms of lists is likely to play well with the rest of how the language is organized. To this end List::Util offers handy functions like max and min, with which you can just type this:

my $least = min(keys %hash); my $largest = max(keys %hash);
This is nice because you solve your problem with hashes, but it also works for any other kind of list. And since Perl passes data by reference, this is fairly efficient.

Now I suggested this in chatter, but unfortunately you had trouble compiling it. But these functions still are not hard to write in native Perl:

sub max { my $max = shift; $max = ($max < $_) ? $_ : $max foreach @_; return $max; }
and min is similar. Plus the corresponding string functions. (The fact that you need to have these pairs of operations - and would need more if you tried adding more basic data types - is something that has been bugging me about Perl lately. Ah well, no language is perfect.)

For a generalization of the problem we also have reduce, which can be implemented in native Perl like this:

sub reduce (&@) { my $op = shift; no strict 'refs'; my $pkg = caller; local *A = local *{"$pkg\::a"}; $A = shift; local *B = local *{"$pkg\::b"}; foreach $B (@_) { $A = $op->(); } $A; }
(Yes, this uses prototypes. And globals.) Now with this single (icky) definition out of the way a lot of list utilities can be written fairly easily. Consider:
sub max { reduce {$a > $b ? $a : $b } @_; }
which as you can see is sort of like the flexibility of sort except for gathering things in a list together, not rearranging them.

Another example to give a sense of what reduce is like:

sub sum { reduce {$a + $b} @_; }

UPDATE
Cleaned up the implementation of reduce slightly.