CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: reports and grouping: Edit Log



lightspd
Novice

Jul 23, 2013, 8:27 AM


Views: 2734
reports and grouping

Hi All,

I'm trying to create a basic report using template toolkit, that has both column and row groups. I have the data, but can't seem to wrap my mind around how to format the output. So for example

Code
my %hash; 
$hash{'2013-01-01'}->{'apples'}->{'qty'} = 3;
$hash{'2013-01-01'}->{'pears'}->{'qty'} = 2;
$hash{'2013-01-01'}->{'peaches'}->{'qty'} = 1;
$hash{'2013-01-03'}->{'peaches'}->{'qty'} = 1;
$hash{'2013-01-03'}->{'apples'}->{'qty'} = 5;
etc.


Now in that case, I want the date to be the column header and fruit to be the row. I can think of how to group by either column or row, but not both. Example output.

Code
         2013-01-01 | 2013-01-03 
apples | 3 | 5
peaches | 1 | 1


I'm open to other suggestions besides toolkit, but I am limited to Perl 5.8.8

EDIT:

I created 2 hashes to pass to template toolkit, one where the main key is date and the other where it's the fruit, using my example code. I would still appreciate feedback as I'm sure my current approach isn't the best.

Cheers.


(This post was edited by lightspd on Jul 23, 2013, 10:33 AM)


Edit Log:
Post edited by lightspd (Novice) on Jul 23, 2013, 8:29 AM
Post edited by lightspd (Novice) on Jul 23, 2013, 8:31 AM
Post edited by lightspd (Novice) on Jul 23, 2013, 10:33 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives