Having read this, and the other node you pointed to, I'm still not quite sure what you're doing. It sounds like you're trying to produce HTML using HTML::Template, yet here you mention HTML::Parser? I dont think writing the HTML out as a Template, and then reparsing it with a Parser to add extra bits is a very good idea.
So it sounds like you need to make something that works together with HTML::Template, or switch to Template Toolkit?
C.