Is it to late to point out that there are tons of very nice templating engines already available, from html::template to ePerl? For a quick overview, you can look at "http://www.perl.com/pub/a/2001/08/21/templating.html", which describes many of the common engines out there.