I have a large script that has no database connection yet. I need one for a tiny new feature. Is it safe to add a naked block to require DBI
where I need it or do I need to import something?
# Lots of no-database code here...
my $obj;
{
require DBI;
my $dbh = DBI->connect('dsn');
$obj = ModuleThatNeedsDBH->new(dbh => $dbh);
}
$obj->fancyStuff();
# More no-database code...
The block is to keep $dbh
hidden from the rest of the program of course.