in reply to CGI question

Massive points off for using do instead of use.

Further, I suspect that the error is in that code since printHeader is not defined in your example and the problem is likely header related.

Check that you are actually printing a header:
my $cgi = CGI->new(); print $cgi->header();
An invalid header is penalized automatically with a "500" error.

For redirection, use:
print $cgi->redirect("some/url");
It is particularily important to note that if your URL is prefixed with "http://" then it is a client-side redirect, where the client will actually fetch a separate Web page and the URL in the browser will change. If it is not prefixed like this, then it is a server-side redirect and the client URL will not change, but the data will. It's a "silent" redirect, if you will.