my $dbh; # Deklaration END { for ($dbh) { $_ and eval{$_->disconnect}; } } $dbh = DBI->connect(....);