chenho has asked for the wisdom of the Perl Monks concerning the following question:
I have a hash with entries composed of records as illustrated in the following:
$record = { EMPLOYER => "company name", EMPLOYEES => ["john", "fred", ...], EMPLOYEES_FAMILY_MEMBERS => {"susan", "bill"}, };
The hash key is the EMPLOYER (i.e.,)
%CompanyInfo{ $record->{EMPLOYER} } = $record;
I want to find all records (by key) that have
EMPLOYEES =~ m/jim/ and EMPLOYEES_FAMILY_MEMBERS =~ m/bill/.
Is there a way to do this w/o a loop? Using grep?
I can search the keys using:
@employer = grep{$_ =~ m/Name/} keys %CompanyInfo;
I don't know how to perform this type of search "deeper into the hash" (e.g., with arrays or hashes within the $CompanyInfo hash).
Thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Searching hashes of hashes ...
by ikegami (Patriarch) on Oct 15, 2007 at 19:29 UTC | |
|
Re: Searching hashes of hashes ...
by GrandFather (Saint) on Oct 15, 2007 at 21:45 UTC | |
|
Re: Searching hashes of hashes ...
by lorn (Monk) on Oct 15, 2007 at 19:22 UTC | |
by perlfan (Parson) on Oct 15, 2007 at 21:46 UTC | |
|
Re: Searching hashes of hashes ...
by naikonta (Curate) on Oct 16, 2007 at 01:27 UTC | |
|
Re: Searching hashes of hashes ...
by chenho (Initiate) on Oct 24, 2007 at 19:20 UTC | |
|
Re: Searching hashes of hashes ...
by princepawn (Parson) on Oct 25, 2007 at 15:37 UTC |