Don't ask to ask, just ask | |
PerlMonks |
Re: Automatic creation of a hash of hashes of arrays (?)by Kenosis (Priest) |
on Jan 27, 2014 at 18:21 UTC ( [id://1072262]=note: print w/replies, xml ) | Need Help?? |
Perhaps the following data structure--a hash of hashes of arrays (HoHoA)--would be helpful (as suggested in your posting's topic):
Output:
The arrays would track both count and locations. On another issue, consider:
instead of using map in a void context, like:
Also, consider using grep or List::Util's first instead of the smart-match operator (see Smart matching is experimental/depreciated in 5.18 - recommendations?):
Output:
The advantage of first is that it terminates upon the first successful find, whereas grep will iterate through the entire list.
In Section
Seekers of Perl Wisdom
|
|