in reply to Get hash value with the lowest key

Just an addition to what the others already mentioned above: If you want to force numeric key sorting, you should use a custom sort block, like this:
#!perl use strict; use warnings; my $href = { '6' => '154', '4' => '152', '1' => '80', '3' => '151', '8 +' => '150' }; my $key = (sort {$a <=> $b} keys %$href)[0]; my $value = $href->{$key}; print "$key => $value\n"; __END__ 1 => 80
Hope this helped.
CombatSquirrel.
Entropy is the tendency of everything going to hell.

Replies are listed 'Best First'.
Re^2: Get hash value with the lowest key
by kiat (Vicar) on Jun 14, 2004 at 10:13 UTC
    Thanks, CombatSquirrel!

    I was wondering why when I have

    my $href = { '11' => '154', '4' => '152', '8' => '150' };
    '11' => '154' was returned as the value instead of '4' => '152'

    Your code solves it :)