jesuashok has asked for the wisdom of the Perl Monks concerning the following question:
Hi all,
I will use the Above sorted user names to display in the web screen.
But suddenly I had a requirement like to get the keys of hash by using the hash values.
Is there a way to get the key of a hash using its values.
Because as per my understanding the keys of Hash can not be duplicate, Even if it is so there is no meaning in having that
can any one have Idea in getting this work ?
Let me brief the basics of hash.
keys %hash; will return the keys available in Hash.
values %hash; will return the values available in Hash.
But Recently I met an Issue as follows :-
my %param; foreach my $values ( sort values %user_details ) { $param{user_name} = $values; }
I will use the Above sorted user names to display in the web screen.
But suddenly I had a requirement like to get the keys of hash by using the hash values.
Is there a way to get the key of a hash using its values.
Because as per my understanding the keys of Hash can not be duplicate, Even if it is so there is no meaning in having that
$hash{1} = 'One'; $hash{1} = 'one'; # No use
can any one have Idea in getting this work ?
"Keep pouring your ideas"
2005-11-17 Retitled by Arunbear, as per consideration
Original title: 'Getting Keys of Hash'
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Getting Keys of Hash from Values
by ikegami (Patriarch) on Nov 16, 2005 at 21:07 UTC | |
Re: Getting Keys of Hash from Values
by duff (Parson) on Nov 16, 2005 at 21:10 UTC | |
Re: Getting Keys of Hash from Values
by davido (Cardinal) on Nov 16, 2005 at 21:14 UTC | |
Re: Getting Keys of Hash from Values
by tmoertel (Chaplain) on Nov 16, 2005 at 21:20 UTC | |
Re: Getting Keys of Hash from Values
by gjb (Vicar) on Nov 16, 2005 at 21:43 UTC | |
Re: Getting Keys of Hash from Values
by GrandFather (Saint) on Nov 16, 2005 at 21:14 UTC | |
Re: Getting Keys of Hash from Values
by injunjoel (Priest) on Nov 16, 2005 at 23:13 UTC | |
Re: Getting Keys of Hash from Values
by ptum (Priest) on Nov 16, 2005 at 21:13 UTC | |
by ikegami (Patriarch) on Nov 16, 2005 at 21:14 UTC |
Back to
Seekers of Perl Wisdom