#!/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 => ' ' } ); } push( @table, { columns => \@row_array } ); } $template->param( table => \@table ); open( TABLE, '>table.html' ) || die($!); print TABLE $template->output(); __DATA__