in reply to Displaying HTML with perl
you could use the template toolkit, which aims to seperate code and web content.
I have not used it, but it is discussed in these books Perl Template Toolkit and Advanced Perl Programming.