good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: Query Array from Hashby crashtest (Curate) |
on Feb 20, 2010 at 00:51 UTC ( [id://824296]=note: print w/replies, xml ) | Need Help?? |
If I understand your objective correctly, I don't think you've picked a good approach for your data structures. You're storing your detail information in @fields, but there is no good way to link your totals back to the details! Given the apparent nature of your data - data sets linked together by a common field - I'd think a hash is the way to go. A hash of arrays (HoA), where each hash entry corresponds to a company, and each array entry is a set of transaction details(?). Instead of just keeping totals in a hash (as you're doing with %sumcredits), keep it all in there! Something like this (untested):
This is how I'd approach it. If you want to stick with using an array to keep your transaction details, you could... but you'd have to loop over the entire array to find the transactions for the company you want to print details on, probably with grep: Depending on the size of your data, I wouldn't really recommend this approach. Conceptually, your data is a HoA (as near as I can tell), so you should represent it as such in Perl. Hope this helps. And, all code above is completely untested and probably littered with typos.
In Section
Seekers of Perl Wisdom
|
|