maybe you don't want to have your script relying on external modules, but I'm going to mention this anyway: try using a templating system, such as
HTML::Template. Your code will be much cleaner, and having your perl code and your html separated is a Good Thing (at least in my book). There are a couple of tutorials here in the monastery that will get you started:
this one by
jeffa and
another one by
Ovid.
hope this helps,