eval { require DBI; DBI->import; # ... as is documented in perlfunc under 'use', # this is same as 'use DBI', except done when the eval {} # is run, not when compiled (eval BLOCK catches only # runtime errors, eval STRING must be used to catch # errors that happen at compile time, but eval BLOCK # is almost always better.) }; if ($@) { # $@ has error from eval, if any. # Couldn't load DBI } else { my $dbh = DBI->connect(...); # Loaded DBI, okay. }