Here's the way I've always done it in order to get totally flexible tables using HTML::Template -- the entire table is an AoHoAoH and you set the number of columns and rows in the code, not the HTML.

It feels a bit kludgy but I'd love monks to help me clean it up if they have any ideas:

#!/usr/bin/perl use warnings; use strict; use HTML::Template; my $template = HTML::Template->new( filehandle => \*DATA ); my $total_cells = 101; my $max_column_height = 25; my $row_width = int( $total_cells / $max_column_height ); my @table = (); my @row_array = (); my %row_hash = (); for ( 1 .. $total_cells ) { push( @row_array, { content => $_ } ); if ( scalar(@row_array) == $row_width ) { my @array = @row_array; push( @table, { columns => \@array } ); @row_array = (); } } if ( @row_array ) { # if there's a row that's incomplete while ( scalar(@row_array) != $row_width ) { push( @row_array, { content => '&nbsp;' } ); } push( @table, { columns => \@row_array } ); } $template->param( table => \@table ); open( TABLE, '>table.html' ) || die($!); print TABLE $template->output(); __DATA__ <table border="1"> <tmpl_loop name="table"> <tr> <tmpl_loop name="columns"> <td><tmpl_var name="content"></td> </tmpl_loop> </tr> </tmpl_loop> </table>


($_='kkvvttuu bbooppuuiiffss qqffssmm iibbddllffss')
=~y~b-v~a-z~s; print

In reply to Re: how to split html printout into two table cells by Cody Pendant
in thread how to split html printout into two table cells by Anonymous Monk

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.