Somebody's going to say this, and I may say it more tactfully than some others: may I encourage you to
use strict and warnings. There are so many reasons why this is a good thing. I used to poo-poo them all but over time my code got claggier and slower and in the end when I made the effort, there was hardly any pain and a sudden improvement in programming style and reliability.
One other advantage: it would probably
make your question easier to answer. As it stands you've posted a longish piece of code, and it's not a costless endeavour to go through it and work out where it breaks. But if you ran it under
strict with warnings enabled, then when it broke you could look at your server error log and it wd likely give you a handy line-referenced message telling you where the problem was. Or if you don't have access to the error log and you can put the following at the top of your code:
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
use CGI qw(:standard);
print header;
warningsToBrowser(1);
Then it sends the error messages to your browser (warnings will show up as HTML comments).
And... then you'll be running CGI.pm which you can use to make yourself MUCH HAPPIER. It really does make sense - I speak as someone who's tried both ways. If you're unconvinced -
use CGI or die;!
At the end of that, if you still can't figure out the problem with all the help that
strict and its pals are giving you, then post again and you'll get a complete answer.
§
George Sherston