in reply to creating report tables

First, I would recommend using some sort of templating system, such as HTML::Template. HTML mixed in with your code is generally frowned upon. Once you've removed the HTML from your code you'll find that it's much easier to read and make improvements to.

In the area of code improvement, I would recommend seperating your code into functions or even to go as far as to split it up into modules if you feel that it's warranted. How far you want to go is up to you, everyone has there own opinion and style.

Lastly, I would recommed that you read the Program Repair Shop and Red Flags series of articles by Mark-Jason Dominus. They'll give great ideas as to how you can improve your code and what to look for that can use improvement.