, .
, . , .
perl , ?
, . eval , - Perl, .
- :
for my $database (@database_list) {
my $dbh;
eval {
$dbh = DBI->connect($database, $user, $password);
};
if (not $@) {
yadda, yadda, yadda
}
}
eval . $@ , , eval - . $@ , , .
HOWEVER . By default, the DBI does not die automatically if it cannot connect. Instead, it simply returns undefined. You should be able to use this to determine if you have succeeded, or if you need to go to the following database:
for my $database (@database_list) {
my $dbh = DBI->connect($database, $user, $password);
if ($dbh) {
yadda, yadda, yadda
}
}
If I remember correctly, there is a RaiseError attribute , which, if set, will cause your program to die if the DBI call fails. However, the default value should not be set, so you should not have a problem.
source
share