Nice to see you solved it. I personally use Template Toolkit (via
Template). In addition to it being very mature, robust, well supported in a number of great Perl webframes, and well documented; it is also very flexible and is basically its own programming language.
So much so that if had been around when Rasmus Lerdorf used Perl to create the first incantations of PHP, I am sure he would have used TT rather than roll his own thing. Ignore that last part, I'm trying to talk you
into using it. xD