in reply to templates vs here docs

... using a here doc and xslt transforms for outputting html ...

In the last months or so I wrote a bunch of Perl scripts for compute cluster control - which do lots of wicked rsh's into a cluster an present nice html output to the coworkers.

I started out w/heredocs, then changed that to qq{..}-strings, then throwed the towel and used (sound on) a nice little module called:

HTML::Template

This was a stunning experience, after (short) working through the details, I ended up with a HTML-File per script (same name as the script + .htm) and several very clean and easy readable Perl scripts.

The proloque to the action would be identical across the scripts, in my case that's sth. like:

... $scriptname = ... # the scripts name (my $srv = $ENV{SERVER_NAME}) =~ s/\..+//; # where are we now my $srvloc = "/srv/web/$srv/html"; # assume directory # prepare HTML output my $template = HTML::Template->new(filename => "$srvloc/cluster/$sc +riptname.htm"); ...

the corresponding html would be edited in Dreamweaver (or whatever you like) and look like:

... <td class="pid"> <TMPL_IF idproc> <a href="/cgi-bin/myprocess.pl/ii/<TMPL_VAR NAME="host">/<TMPL_VA +R NAME="pid">" title="[pid No.]"><TMPL_VAR NAME="pid">&nbsp; </a> </TMPL_IF> </td> ...

The variables set in the perl program would show up in the html as

<TMPL_VAR NAME="varname">

and the perl program would set the variables like:

... $template->param( host => $host, cpuid => $cpuid, cpuidcolor => $cpuidtab{$cpuid} ); ... ... print "Content-type: text/html\n\n", $template->output;

where he last line would send the html to the browser.

So that's what I'd recommend. HTML::Template is ideal suited for this kind of CGI-script things.

Regards

mwa