|laziness, impatience, and hubris|
Re: question about what to grep(?)by Don Coyote (Pilgrim)
|on Apr 12, 2013 at 11:46 UTC||Need Help??|
I will expect you mean the values of the keys of the hash are arrays, which is a common structure. For selecting, grep is a good operator. You also want to understand how to access the arrays to carry out the conditional test.
To build an array of the keys of arrays held by the keys of baskets which have 10 items or less:
In this example, we access the array by providing the hashvalue through the key and dereferencing it with the array sigil and curly braces. Obtaining the scalar context of number of items.
You can now happily process the baskets in your 10 items or less queue, the baskets with more having been laser blasted to smithereens.
Of the baskets holding the requisite number of items, some contain goods other than groceries, such as hero equipment, which need to be checked out in the kickass department. Now we really need to access the items inside the arrays. To do this we pass in our newly formed list to a further grep. Similar to adding further foreach loops.
All we need to watch for is assigning the special variable $_ in each 'outer' grep we use so we can repel magnetic pulse traps and displace gravity gracefully.
grep, foreach for heros and heroines!