in reply to overuse of CGI module HTML methods?

Forgetting the whole separate design from code question, incidentally.

You can't really do that, being a programmer. It isn't so much a question of design/code, but of dynamic/static.

Stitching together static text dynamically via costly sub calls (yes, subroutine calls in perl are costly) every time you output the same chunk of data is unwise and inefficient, no matter whether your usage of the underlying module to do that is efficient or not.

Then there's the question of maintainability. Inserting another row of label/text fields is tedious at the same level as with plain html code, so nothing gained here either. I'd use at least a structure like

# Table data my @rows = ( ['FaultFinder ID', [{ id => 'ff-job-id' }] ], ['Username', [{ id => 'searchby-user'}] ], ['Status', [{ id => 'searchby-status'}] ], ['Time', [ { id => 'searchby-date-start', label => 'begin', onchange => 'checkDate(this)', }, { id => 'searchby_date_end', label => 'end', onchange => 'checkDate(this)', }, ] ], ['', [ { id => 'right_submit_button', type => 'submit', onmousedown => "checkForm('searchForm')", value => 'Go', }, { id => 'submitted', type => 'hidden', value => 'get_existing_ff', }, ] ] );

to hold the relevant data, document that structure and organize my code to deal with that structure. That way if you ever were to insert a row containing e.g. a database identifier against which to run the search (or such), you haven't got to go through your code to find the right place, but just add an element to that array.

update:

The generating code could be in terms of CGI, or something else. I prefer HTML::Writer to produce templates or static HTML files.

#!/usr/bin/perl # use HTML::Writer qw(xhtml1-strict.dtd); # above @rows definition goes here. render { HTML { HEAD { TITLE { "Some Form" } }; BODY { FORM { action_ "/cgi-bin/ff-webclient.pl"; name_ "searchForm"; id_ "searchForm"; FIELDSET { LEGEND { 'Query finished/currently running jobs' }; DIV { class_ 'instructions' }; TABLE { for (@rows) { my ($label, $inputs) = @$_; my $cs; TR { if ($label) { TD { LABEL { class_ 'small'; for_ $inputs->[0]->{id}; $label; }; }; } else { $cs = 2; } TD { $cs and colspan_ $cs; for ( @$inputs ) { if ($_->{label}) { t $_->{label}; BR {}; }; INPUT { type_ $_->{type} || 'text'; name_ $_->{id}; id_ $_->{id}; $_->{value} && value_ $_->{value}; $_->{onchange} && onchange_ $_->{onchange}; $_->{onmousedown} && onmousedown_ $_->{onmousedo +wn}; }; BR {} if @$inputs > 0 and $inputs->[-1]->{id} ne $_->{id}; } }; }; } }; }; }; }; }; } 1;

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}