in reply to Find all keys from a value in a hash
Note: %idx_fruit is a hash, but contains members as hash references. This is to provide natural semantics for managing the membership sets and accessing values (e.g., delete, exists, etc). The value => 1 is meaningless, but might be useful for some additional meta data. You could even have them point to the reference of the member in %fruit for maximized fun.my $search = "red"; my %fruit = ( 'apple' => ['red','green'], 'kiwi' => 'green', 'banana' => 'yellow', ); my %idx_fruit = ( 'red' => {'apple' => 1 }, 'green' => {'apple' => 1, 'kiwi' => 1 }, 'yellow' => {'banana' => 1}, );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Find all keys from a value in a hash
by Anonymous Monk on Nov 11, 2021 at 14:11 UTC | |
by Marshall (Canon) on Nov 11, 2021 at 21:35 UTC |