Problems? Is your data what you think it is? | |
PerlMonks |
Re^3: Pivoting parts of a database table into an HTML tableby jandrew (Chaplain) |
on Oct 22, 2012 at 17:45 UTC ( [id://1000392]=note: print w/replies, xml ) | Need Help?? |
Athanasius's solution is the traditional perl solution for the problem you presented. In other words put the data in a hash (to organize the pivot) and then post process the output.
If the goal is to use chapter 4 of Dominus's book to minimize memory overhead then you really just have a recursive problem where you need to identify your base state. (a change of date) You might find the following useful in that case. The data must be pre-sorted by date for this to work. Width formatting is not possible in this output since the data will be printed prior to a test of all rows. That shouldn't be a problem for your suggested goal of web output.
Produces this output
Update1: changed for to while to honor the iterator concept
Update2: I just noticed I didn't pick up the last line (no base state test when the query ends. (fixed))
Update3: fetchrow_hashref is a better fit and can be used with sort
In Section
Seekers of Perl Wisdom
|
|