in reply to Connecting to Oracle DB using DBI from CGI script

See the DBI documentation for the connect method, which explains how to trap connection errors. Also you have use CGI; but don't seem to use it. Consider reading Ovid's CGI Course - Resurrected and Updated! and CGI Programming from the tutorials section.