The Many Ways to Make a Simple Table
#!/usr/bin/perl -w

use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser); # Makes die work acceptably! Very important!!

@headers = ("State", "City", "High Temperature", "Low Temperature");
@rows    = ("Oregon,Tillamook,77,65", "Nevada,Tonopah,95,64",
            "South Dakota,Rapid City,88,57", "Nevada,Reno,90,48",
            "Arizona,Gila Bend,113");

print header, start_html;

push(@lines, th(\@headers));

foreach $row (@rows)
{
     ($state, $city, $high, $low) = split /,/, $row;
     push(@lines, td({-align => 'center'}, [$state,$city,$high,$low]));
}


print table({-rules => 'all'}, Tr(\@lines));


#####  or ...

@lines = ();

push(@lines, th(\@headers));

foreach $row (@rows)
{
     ($state, $city, $high, $low) = split /,/, $row;
     push(@lines, Tr(td({-align => 'center'}, [$state,$city,$high,$low])));
}

print table({-rules => 'all'}, @lines);


#####  or ...

@lines = ();

push(@lines, th(\@headers));

foreach $row (@rows)
{
     ($state, $city, $high, $low) = split /,/, $row;
   
     $thisrow = "";
     foreach $field ($state, $city, $high, $low) 
     {
         $thisrow .= td({-align => 'center'}, $field);
     }
     push(@lines, Tr($thisrow));
}

print table({-rules => 'all'}, @lines);