in reply to how to find a key from a hash

You can always get at the first key and the first value of a hash by looking at the hash as a list:

my ($key,$value) = %hash;

If your hash has more than one key, you will get a key, but as a hash is not ordered, there is no guarantee that you will get a specific key.

Replies are listed 'Best First'.
Re^2: how to find a key from a hash
by grinder (Bishop) on Nov 21, 2005 at 16:29 UTC

    Or slice it out:

      my $key = (keys %hash)[0];

    • another intruder with the mooring in the heart of the Perl