Not that I know exactly what is going wrong here, but can you try running the script from the command line? I have found that by the output of the script (namely the HTML code that is produced) you can decipher where it is hanging and this will get you on the road to where you need to be.
I don't know if it will work in your case, because it looks like your running windows, but it's worth a try. Unfortunately I don't have the access between my two machines, this one and the one I can run Perl on, so I can't try it for you.
I hope that maybe this idea will help you decipher your problem. Other than that, get some sleep, it always helps!!