It appears that you aren't using CGI.pm (using it is a Good Idea) so if you want to test your program with variables, you can either just write them into the program ($cgi_var = "foo";) or you can use the perl debugger (with perl -d) and set variables by hand there.
You should be able to see your errors in the server error log, and if you want errors to go to the browser, take a look at CGI::Carp. use CGI::Carp qw(fatalsToBrowser); will send error messages to the browser.