I want to use grep or map for the following refrence to find the child keys of 'Orange'.
My bold emphasis added.
my @o_kids = map { keys %{$xml->{Fruits}[0]{'Season'}{$_}} } grep /orange/i, keys %{$xml->{Fruits}[0]{'Season'}};Uses all the keywords from your question. But I suspect, as other have mentioned, that you are not asking the right question.
Note that this solution requires you to know that (1) Fruits is an array ref (2) Orange is a key to the 'Seasons' hashref, etc. All of which means you have a rather intimate knowledge of the data structure. Unless this is homework in how to use grep, map (and aparently foreach), there is something else you're trying to accomplish.
In reply to Re: grep in hash of array
by chakram88
in thread grep in hash of array
by rose
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |