http://qs321.pair.com?node_id=185071

blokhead has asked for the wisdom of the Perl Monks concerning the following question:

It seems like every time a write a new CGI app, I take a different approach on how to get HTML to look reasonable inside my code. I can't seem to find the perfect way to do so. I'm sure some monks out there have some great ideas I haven't thought of yet. For getting HTML to not look horrid in Perl, I've tried various things. The tag-generation code in CGI.pm is certainly OK, but that seems like it's best suited for simpler applications. The output is ugly, however I've written my own replacement to fix that. And autoescaping aside, I think print $q->table({border=>0,cellpadding=>0,cellspacing=>0,bgcolor=>"#ffffff"},$stuff) can get a little out of hand when compared to  print qq[<table border=0 cellpadding=0 cellspacing=0 bgcolor=#ffffff>$stuff</table>] (OK, so maybe I hate writing out everything into an anonymous hash) Then there's templating the HTML, which is a great way to separate it out of your Perl, except eventually the templating system must be its own programming language or else not all of your HTML stays away from the Perl. I usually need the templates to be simple so the HTML jockeys don't have to learn a scripting language. Recently I've discovered Interpolation.pm, so I can do stuff like:
print qq|<a href="blah.cgi?search=$M{param("search")}">link</a>|; # %M is tied to some mime encoding function
I'm still getting the hang of this, but it certainly doesn't solve all the nuisances of combining HTML with Perl. I'd like to know what the rest of the world does to cope with these issues ;) Thanks!