#!/usr/bin/perl -w
use strict;
#the rest of your code
(where /usr/bin/perl is the location of perl on your computer)
Now you will get all kinds of helpful error messages when you try to run the script. With the help of these messages, 30 cups of coffee, and possibly some valium you should be able to find the bug ;)
Oh, and the use strict thing causes perl to be tougher on you in terms of what it lets you get away with. This tends to keep you from doing things by mistake that really shouldn't be allowed.
If you don't have access to the error log, then add this to your code, which causes fatal errors to be output to the browser.
#!/usr/local/bin/perl -w
use CGI::Carp qw(fatalsToBrowser);
use strict;