print table(thead(Tr(th(...), th(...))), tbody(Tr(td(...), td(...), ...)));Unfortunately the contents of the table tag were somewhat huge, so Perl grabbed most of the memory on the web server in its attempt to prepare the string for printing, causing all sorts of nastiness.
What I needed was some way to generate and print the table tag without the table contents and end tag, and ideally the same for tbody, and maybe thead and even tr for good measure. I thought I'd have to generate the table with a dummy placeholder and split the string manually, something like this:-
my $table_container = table('CUT HERE FOR PRINTING');then find my string, print the bit before it, print the table contents, then print the bit after it. Yuk!! So I resorted to Google for inspiration and tried "cgi.pm start_table". Hey, presto! There was the answer, in the CGI.pm documentation itself, and it uses start_table as the example:-
use CGI qw/:standard *table start_ul/;This generates functions start_table, end_table, start_ul and end_ul which behave just the way you'd expect. In hindsight there's a clue to this, because the standard function set includes start_html and start_form, so good ol' Lincoln was well ahead of the game.
Right, back to that CGI script...