Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl my $search = "red"; my %fruit = ( 'apple' => ['red','green'], 'kiwi' => 'green', 'banana' => 'yellow', ); my ($match) = grep { $fruit{$_} eq $search } keys %fruit; print "\n\n Match = $match\n\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Find all keys from a value in a hash
by haukex (Archbishop) on Nov 09, 2021 at 21:16 UTC | |
|
Re: Find all keys from a value in a hash
by Fletch (Bishop) on Nov 09, 2021 at 20:55 UTC | |
by Anonymous Monk on Nov 09, 2021 at 21:00 UTC | |
by Anonymous Monk on Nov 10, 2021 at 12:31 UTC | |
|
Re: Find all keys from a value in a hash
by LanX (Saint) on Nov 09, 2021 at 20:58 UTC | |
|
Re: Find all keys from a value in a hash
by perlfan (Parson) on Nov 10, 2021 at 16:37 UTC | |
by Anonymous Monk on Nov 11, 2021 at 14:11 UTC | |
by Marshall (Canon) on Nov 11, 2021 at 21:35 UTC |