Hey,
I'm trying to create an HTML table of the powers of 2,3, and 4. It se
+ems to be working. The only problem is that the html_table() subrout
+ine is printing out both calls that i made to it ($table1, and $table
+2), instead of just one ($table2).
Thanks,
Kiko
#!/perl/bin/perl
print "Content-type: text/html\r\n\r\n";
# generate an HTML table of the powers of 2,3 and 4
$rows[0] = html_row("white"," n " ,
"nth power of 2",
"nth power of 3",
"nth power of 4");
for ($i=0;$i<10;$i++) {
if ($i % 2) {
$rows[$i+1] = html_row("#cccccc",$i,2**$i,3**$i,4**$i);
} else {
$rows[$i+1] = html_row("#ccccff",$i,2**$i,3**$i,4**$i);
}
}
$table = html_table(1,"",@rows);
$table2 = html_table(0,"black",html_row("",$table));
print "Here are the powers of 2, 3 and 4<BR><BR>\n";
print "$table2";
# This subroutine will print out a table row
sub html_row {
local($color, @row)=@_;
$rowP.="<TR BGCOLOR=$color>";
foreach $a (@row) {
$rowP.="<TD> $a </TD>";
}
$rowP.="</TR>\n";
return ($rowP);
}
# This subroutine will print out an HTML Table
sub html_table {
local($border,$color,@table_row)=@_;
$tableP.="<TABLE BORDER=$border BGCOLOR=$color>\n";
foreach $b (@table_row) {
$tableP.="$b";
}
$tableP.="<TABLE>\n";
return ($tableP);
}