#!/usr/bin/perl
use CGI;
use HTML::Template;
use strict;
# Define the colour of the background variable, $bgcolor
#
my ($bgcolor) = "000000";
# Create CGI object
#
my ($cgi) = CGI->new();
# Create HTML::Template object, use template.html
#
my ($html) = HTML::Template->new(
filename => 'template.html'
);
# Substitute the value of $bgcolor into template.html
#
$html->param(
'bgcolor' => $bgcolor,
);
# Print the output
#
print STDOUT $cgi->header(), $html->output;
exit 0;
####
An example template file
">
####
$bgcolor = ($cgi->param('bgcolor') =~ /^[\da-fA-F]{6}$/) ? $cgi->param('bgcolor') : $bgcolor;