Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I want to do something different for the keys that have only 1 hash refs after it. I can easily check whether that is the case using:$hash{key1}{value1} = 1; $hash{key1}{value2} = 2; $hash{key2}{value3) = 1;
Where $key is passed to the function. However, I have no way of knowing what "valueN" is without doing something like:my $check = scalar keys %{$hash{$key}};
It seems that there should be a more elegant way to pull the value of $k without using a foreach loop.forach my $k (keys %{$hash{$key}}) { # $k == the value i am looking for. }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: determine a hash key
by broquaint (Abbot) on Nov 01, 2002 at 14:19 UTC | |
|
Re: determine a hash key
by artist (Parson) on Nov 01, 2002 at 18:49 UTC |