my $dbh = "123456"; # just as a test, instead of DBI->connect(....); if ($dbh != valid_DBI_handle()) { print "please supply a PROPER reference to a DBI object, or whatever it's called\n"; } else { # okay, dbh actually points to a real db connection print "dbh is truly valid"; } #### if (!$dbh) { die "no db connection!"; } else { $dbh->run_some_command(); }