in reply to For statement 2 html table

The idea of using something like HTML::Template is definitely worth looking into -- it can simplify your perl code a lot, and make it easier to tweak/fix the HTML display without having to change the perl code.

Based on the code you've posted, it's not clear to me (because I lack CSS experience) how the div and br tags are being transformed into a table layout. In any case, if I were to try to do this without HTML::Template, it would probably look something like this (note that I'm not using div or br tags, either, but maybe you can work that out yourself, if it matters):

# create a reference to a hash with @$times as keys and values: my $times_href = { map { $_ => $_ } @$times }; # add the image tagging to the $icon elements: $icons->{$_} = "<img src=\"$icons->{$_}\" alt=\"\" />" for ( keys %$ic +ons ); print "<table>\n"; for my $dref ( $icons, $times_href, $conditions, $hilo, $temperatures +) { print "<tr>"; print "<td>$dref->{$_}</td>" for ( @$times ); print "</tr>\n"; } print "</table>\n";
(not tested)

Since most of your data is in hash refs already, putting the @$times data into a hash ref as well means that you can treat all the table rows the same way, and you still use @$times to run the loop that prints the columns on each row in the proper order.

(updated to add (and fix) the for loop that modifies the contents of the $icons hash ref, so that they can also be used the same way as the other hash refs when printing the table)

(another update: I realize that I've left out some of the details in the OP code, like adding the "°F" on the temperatures, the "abbr" tags, etc. But these would be handled the same way as adding the "img" tagging on the "%$icons" data.)

Replies are listed 'Best First'.
Re^2: For statement 2 html table
by senik148 (Beadle) on Jan 04, 2006 at 17:10 UTC
    Thanks, your code did the job!


    i was looking at html::template before, tryng to look for a solution. thanx to all of you!