![]() |
|
"be consistent" | |
PerlMonks |
an easier way with grep, map, and/or sort?by aufrank (Pilgrim) |
on Jul 19, 2002 at 17:18 UTC ( #183320=perlquestion: print w/replies, xml ) | Need Help?? |
aufrank has asked for the wisdom of the Perl Monks concerning the following question:
I feel like I should go to confession to say this, but here goes: I'm not very good with map, and terrible with sort and grep. I am, however, getting to the point that I can tell when I should be using one of these functions, and I think I've found just such a case. Sadly, I don't know what to do now, as I certainly don't want to go on write more unnecessary and inefficient lines of code, but don't have the skills I need to do it in better way.
I need to go through an array of hashes where the hashes all have the keys instiution, race, age. I need to know how many men in various age ranges are enrolled in each institution, and how many men of those age ranges are of each race. I started to do something like this: aside from being really ugly, I'm pretty sure it's not even close to being the best way to do this. I've got a strong intuition that the answers lie in doing sexy things with grep, map, and/or sort, but that's about all I've got (aside from a pile of ugly code). So, any suggestions on how to find the number of men in each age range at each hospital?
thanks for any help,
Back to
Seekers of Perl Wisdom
|
|