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

Hi,
I'm using CGI to write tables. Works fine, except for that I can't find out how to set individual column properties. I'd like to do that in the following example, how do I do it?
print Tr({-align=>'center',-valign=>'top',-bgcolor=>$trBgColor}, [ th(['Column1','Column2','Column3']) ]);

Replies are listed 'Best First'.
Re: Simple question regarding CGI and printing tables
by thomas895 (Deacon) on Mar 19, 2012 at 13:06 UTC

    All you have to do is to declare them for each cell. That made no sense, so here's an example:

    print Tr( {-align=>'center',-valign=>'top',-bgcolor=>$trBgColor}, [ th( { -style => "background: #ffffff" }, "Column1" ), th( { -style => "background: #cccccc" }, "Column2" ), th( { -style => "background: #ffffff" }, "Column3" ), ] );
    ~Thomas~
Re: Simple question regarding CGI and printing tables
by tobyink (Canon) on Mar 19, 2012 at 14:28 UTC

    Stop thinking "what Perl can I write to accomplish this effect?" and start thinking "what HTML can I write to accomplish this effect?"

    Once you know the HTML you need, then writing the Perl to generate that HTML should be simple. There are two layers to this problem - figure them out separately.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
      Well, I know the html i'd like to create, I'm using CGI to make the code a bit cleaner.
Re: Simple question regarding CGI and printing tables
by Anonymous Monk on Mar 19, 2012 at 13:58 UTC