This may or may not be a Perl question. The real question is in where it went wrong. (wrong being completely subjective, when it comes to dealing with HTML)
If the CGI didn't generate the HTML that you were expecting, then it's an issue with the script, so it's a Perl question. If the "correct" HTML doesn't generate the result as expected in the browser, then it's either an HTML or a browser issue. (yes, they're different things -- see quirksmode)
Take the output of your script, then compare the results of it to what you were expecting. Modify the HTML until you get the browser results that you were expecting, check it against a validator to make sure it's valid HTML, and then modify the script so that it's producing the HTML that you want.