Wet behind the...

This is the first time I've built something like this. This is the work script I wrote, to figure out how to do it. The real script is part of a much larger application.

What I'd like to know is, is there a more elgant way to do this? I don't think this is that bad, but I know there's always a way to use less code. I was also wondering if there is a standard way that a more experienced person would do this.

You can ignore the href's, they're part of the use of this table, long story.

#/usr/bin/perl print "Content-type:text/html\n\n"; print "<html><head><title>Build Table.pl</title></head>\n"; print "<body>\n"; $total_cells = 517; # would be recordset $display_cells = $total_cells / 15; $row_count = 10; # rows for my table $col_count = $display_cells / $row_count; # cols I'll have print "<table cellpadding=\"4\" border=1>\n"; # counters $row_inc = 1; $col_lable = 1; $nav_count = 15; $nav_inc = 15; for($r = 1; $r <= $row_count; $r++) # build rows { print "<tr>\n"; for($c = 0; $c < $col_count; $c++) # build cols { if($nav_count < $total_cells) { print "<td><a href=\"mypage.html?nav=$nav_count\">$col_lab +le</a></td>"; } else { print "<td>&nbsp;</td>"; } $col_lable+=10; $nav_count+=150; } print "</tr>\n"; $row_inc++; $col_lable = $row_inc; $nav_inc+=15; $nav_count = $nav_inc; } print "</table>"; print "</body></html>\n";

In reply to Dynamic Table by Dufonzo

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.