I think what you are looking for is a AOHOH, but my preference would be to let the database (SQL) do the aggregation and grouping.
The AOHOH would be:
my @db;
$db[$monthNumber]->{ProductName}{RegionName} = $Quantity;
# Loop through Month..
for (0..11){ #Cycle through Months, assuming zero-based
next unless my %prod = %{$db[$_]}; # Any data there ?
print "Some MONTH $_ header here\n";
foreach (sort keys %prod){
my %region = %{$prod{$_}};
# $region{RegionName} now has the qty to be printed
# Hopefully, you get the idea now...
}
}
Needless to say, the code above is untested..
..."I don't know what the facts are but somebody's certainly going to sit down with him and find out what he knows that they may not know, and make sure he knows what they know that he may not know, and that's a good thing. I think it's a very constructive exchange," --Donald Rumsfeld
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.