in reply to Best way to store/sum multiple-field records?

The best way is definitely to use a hash of hashes, as shown by toolic. Nothing complicated in that case really try to use his proposal.

Now, if you don't feel comfortable with nested data structures, you have the right to use two hashes, one for summing the values, and another one for the mapping of USERIDs to names.

This is maybe slightly less efficient (at least in terms of coding and possibly storing performances), but do we care, provided that it does what you want? No, we usually don't.

Perl has a tradition of being nice with people writing "baby Perl", i.e. using only a relatively small subset of the language. As chromatic says in the Modern Perl book, "this baby Perl is a term of endearment, because everyone begins as a novice." The Programming Perl (or "Camel book") reference book is on the same line. And this is also my personal experience: I am rather happy that I have no longer have the source of my first Perl programs, I would probably find them very badly written. Yet, they did what I wanted, and they did it quite efficiently.

  • Comment on Re: Best way to store/sum multiple-field records?