The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


HTML::WTweb - A simply and relatively efficient HTML template system.


       use HTML::WTweb;
       my $WT = HTML::WTweb->new();
       $WT->processhtml(FileName => "test1.html",
                        Header => 1,
                        -title => "hello universe",
                        -ptag  => "citzens of the sky");
       my @planets = ("venus", "mars", "jupiter");
       foreach my $p(@planets){
                               $WT->processhtml(FileName => "test2.html",
                                                -planet => $p);
       undef $WT;

Where test1.html and test2.html are something like this:

       <p>here are the -ptag</p>

and <p>I came here from -planet</p>


sethtmldir: sets the directory where html template files are placed.

fileload: load one or more template from htmldir.

processhtml: operate the parsing, substitutions and output to stdout of the given template.

I suggest you to use CGI module instead my poor "Header" switch to print out canonical header if you also need to retrieve form parameters from a previous post.

The directory where html templates are stored should be ./html, I haven't tried to put them elsewhere

/usr/local/apache/myweb <- perl code

/usr/local/apache/myweb/html <- html templates


This module must be interpretated as a preliminary release of a more complete package suite. Using WTweb make easy to detach the crummy html tags from the beauty of perl, in a simply and synthetic way. It won't be the top of efficiency, but it's simply and intended to reliate headache arised from the tedious web applications. It may also used as generic text-template system.


Gian Maria Gamboni <>


Copyright (c) 2005 Gian Maria Gamboni - All Rights Reserved This code is free software and you may redistribuite or modify it under the same terms as Perl itself.