in reply to Re: How to get Keys from hash having same value?
in thread How to get Keys from hash having same value?
Or, to avoid the extra hash lookups, iterate over key-value pairs using each.
my @as = (); while (my ($key, $value) = each %myhash){ push @as, $key if $value eq 'a'; }
Update:
Is there a monk among us who can shorten this into a one-liner, similar to the grep keys examples we have seen?
It seems that each does not combine nicely with grep, map and their ilk.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: How to get Keys from hash having same value?
by shmem (Chancellor) on Jan 07, 2008 at 14:19 UTC | |
Re^3: How to get Keys from hash having same value?
by targetsmart (Curate) on Jun 03, 2008 at 13:22 UTC |
In Section
Seekers of Perl Wisdom