I don't see anything in your script that would cause the issue you're having, but I do see a number of things that could be done to make the script easier to read/maintain.

You might want to add the CGI::Carp module to get a better (more detailed) error message.

Code

use CGI::Carp qw(fatalsToBrowser);

Based on the syntax you're using on the vars I'd say you must be a shell programmer.

Using all uppercase var names makes the code harder to read and you rarely need to use the braces around the names. The parens in the var assignments are also not needed, unless you need list context, which your code doesn't.

The CGI or CGI::Simple module would help in cleaning up the html output. And maybe even use the CGI::Pretty module instead of hard coding the \t indentation.

Instead of using the $sth->fetch method, I'd probably use the $sth->fetchrow_hashref method.

Thanks for your reply. I'm not a shell programmer per se but I have done more shell than perl. Thanks for the hints. Unfortunately I can't check the memory etc just now as I'm not at the office. I'll check tomorrow and post back.