in reply to cgi problem

I don't get why and what for you need the colonna of prints in the end of your script. Let CGI.pm do that stuff for yozu, so you need fewer prints. And which errors do you get ?? Where? And why don't you use strict?

Have a nice day
All decision is left to your taste
Update
You also have some my declarations inside "For" loops, so they get a value assigned but can't carry that outside their scope.