Two things:
  1. use CPAN! This includes using CGI as well as the strict and warnings pragmas.
  2. Insert the items by columns then rows -- not by rows and then columns.
use strict; use warnings; use CGI::Pretty qw(:standard); my $total_cells = 517; # would be recordset my $display_cells = $total_cells / 15; my $row_count = 10; my $col_count = $display_cells / $row_count; my $col_lable = 1; my $nav_count = 15; my @table; for my $c (0..$col_count) { for my $r (0..$row_count-1) { $table[$r]->[$c] = ($nav_count < $total_cells) ? a{href=>"mypage.html?nav=$nav_count"},$col_lable : '&nbsp;' ; $col_lable += 1; $nav_count += 15; } } print header, start_html('Build Table.pl'), table({cellpadding=>4,border=>1}, map {Tr[td[@$_]]} @table), end_html, ;
I am sure there is more refactoring that could be done, but this should get you started. ;)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to (jeffa) Re: Dynamic Table by jeffa
in thread 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.