echoangel911 has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I was wondering how you can reference like this :
print $query->table({-border=>undef}, caption('When Should You Eat Your Vegetables?'), Tr({-align=>"CENTER",-valign=>"TOP"}, [ th(['Vegetable', 'Breakfast','Lunch','Dinner']), td(@Data1), td(@Data2), td(@Data3), ... ] ) );
I was wondering how can I put a loop such that each time, I enter a new row of data

Replies are listed 'Best First'.
Re: Dynamic Tables in CGI.pm
by rodion (Chaplain) on Aug 15, 2006 at 22:44 UTC
    I'll take you one step further, moving the row definitions up top and defining an array ref to put the rows into. You should be able to put the "push" lines in a for loop from here.

    Good luck.

    my $rowRef = [th(['Vegetable',Breakfast','Lunch','Dinner'])]; push @$rowRef, td(@Data1); push @$rowRef, td(@Data2); push @$rowRef, td(@Data3); ... print $query->table({-border=>undef}, caption('When Should You Eat Your Vegetables?'), Tr({-align=>"CENTER",-valign=>"TOP"}, $rowRef ) );
      looks good! i will try it
Re: Dynamic Tables in CGI.pm
by andyford (Curate) on Aug 15, 2006 at 22:19 UTC
    I can't say that I'm real clear on your question, but you probably need to create your arrays first, and then use the CGI.pm table methods to display them.