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); }

In reply to HTML Table Using Perl by Kiko

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.