in reply to Check if DBI is installed
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. }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Check if DBI is installed (eval to check module is installed)
by mandog (Curate) on Sep 02, 2001 at 10:18 UTC | |
by tachyon (Chancellor) on Sep 02, 2001 at 16:19 UTC |