[Melbourne-pm] DBI connect()'s, scope and disconnects
Leigh Sharpe
lsharpe at pacificwireless.com.au
Thu Jul 26 21:14:10 PDT 2007
Hi All,
Can someone clear up a couple of things for me here?
I have some code which does something like this:
foreach(@an_array)
{
my $dbh=DBI->connect($dsn);
# Do some other stuff here.
last if (some_condition == true);
$dbh->disconnect();
}
Question is, if some_condition is true, the loop ends and $dbh goes out
of scope. Does disconnect() get called on $dbh automatically? Or do I
have a database connection still, even though I can't actually use it?
This could cause grief for the database server if stale connections are
still hanging around.
On a related note, does disconnect() get called automatically when a
program ends? Even if not explicitly called?
Regards,
Leigh
Leigh Sharpe
Network Systems Engineer
Pacific Wireless
Ph +61 3 9584 8966
Mob 0408 009 502
Helpdesk 1300 300 616
email lsharpe at pacificwireless.com.au
web www.pacificwireless.com.au
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/melbourne-pm/attachments/20070727/f49ff97d/attachment.html
More information about the Melbourne-pm
mailing list