<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="MSHTML 6.00.2800.1491" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=048535603-27072007><FONT face=Arial size=2>Hi
All,</FONT></SPAN>
</DIV>
<DIV><FONT face=Arial size=2><SPAN class=048535603-27072007>Can someone clear up
a couple of things for me here?</SPAN></FONT>
</DIV>
<DIV><FONT face=Arial size=2><SPAN class=048535603-27072007>I have some code
which does something like this:</SPAN></FONT>
</DIV>
<DIV><FONT face=Arial size=2><SPAN class=048535603-27072007></SPAN></FONT><FONT
face=Arial size=2><SPAN class=048535603-27072007></SPAN></FONT>
</DIV>
<DIV><FONT face=Arial size=2><SPAN
class=048535603-27072007>foreach(@an_array)</SPAN></FONT>
</DIV>
<DIV><FONT face=Arial size=2><SPAN
class=048535603-27072007>{</SPAN></FONT>
</DIV>
<DIV><FONT face=Arial size=2><SPAN
class=048535603-27072007></SPAN></FONT>
</DIV>
<DIV><FONT face=Arial size=2><SPAN class=048535603-27072007>
my $dbh=DBI->connect($dsn);</SPAN></FONT>
</DIV>
<DIV><FONT face=Arial size=2><SPAN class=048535603-27072007> #
Do some other stuff here.</SPAN></FONT>
</DIV>
<DIV><FONT face=Arial size=2><SPAN class=048535603-27072007>
last if (some_condition == true);</SPAN></FONT>
</DIV>
<DIV><FONT face=Arial size=2><SPAN class=048535603-27072007>
$dbh->disconnect();</SPAN></FONT>
</DIV>
<DIV><FONT face=Arial size=2><SPAN
class=048535603-27072007></SPAN></FONT>
</DIV>
<DIV><FONT face=Arial size=2><SPAN
class=048535603-27072007>}</SPAN></FONT>
</DIV>
<DIV><FONT face=Arial size=2><SPAN
class=048535603-27072007></SPAN></FONT>
</DIV>
<DIV><FONT face=Arial size=2><SPAN class=048535603-27072007>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.</SPAN></FONT>
</DIV>
<DIV><FONT face=Arial size=2><SPAN
class=048535603-27072007></SPAN></FONT>
</DIV>
<DIV><FONT face=Arial size=2><SPAN class=048535603-27072007>On a related note,
does disconnect() get called automatically when a program ends? Even if not
explicitly called?</SPAN></FONT>
</DIV>
<DIV><FONT face=Arial size=2><SPAN
class=048535603-27072007></SPAN></FONT>
</DIV>
<DIV><FONT face=Arial size=2><SPAN
class=048535603-27072007></SPAN></FONT>
</DIV>
<DIV><FONT face=Arial size=2></FONT>
</DIV>
<DIV><FONT face=Arial size=2></FONT>
</DIV>
<DIV align=left>
<DIV align=left><FONT face=Arial
size=2>Regards,<BR>
Leigh</FONT>
</DIV>
<DIV><FONT face=Arial size=2></FONT>
</DIV>
<DIV><FONT face=Arial size=2>Leigh Sharpe<BR>
Network Systems Engineer<BR>
Pacific
Wireless<BR>
Ph +61 3 9584 8966<BR>
Mob 0408 009 502</FONT>
</DIV>
<DIV><FONT face=Arial size=2>Helpdesk 1300 300 616<BR>
email <A
title=mailto:lsharpe@pacificwireless.com.au
href="blocked::mailto:lsharpe@pacificwireless.com.au">lsharpe@pacificwireless.com.au</A><BR>
web
<A title=http://www.pacificwireless.com.au/
href="blocked::http://www.pacificwireless.com.au/">www.pacificwireless.com.au</A></FONT>
</DIV></DIV>
<DIV><FONT face=Arial size=2></FONT>
</DIV></BODY></HTML>