[Melbourne-pm] DBI connect()'s, scope and disconnects
Brendon Oliver
brendon.oliver at gmail.com
Thu Jul 26 21:32:15 PDT 2007
On Friday 27 July 2007 14:27:52 Leigh Sharpe wrote:
> >foreach(@an_array)
> >{
> > my $dbh=DBI->connect($dsn);
> > # Do some other stuff here.
> > $dbh->disconnect();
> > last if (some_condition == true);
> >}
> > seems to me to make more sense that way...
>
> Except when you want to keep using the connection if the condition is
> false.
well.. you didn't say there was more stuff between the 'last if...' and the
disconnect() in your example ;-)
Also, unless the DBI->connect($dsn) in your loop has some magic which pools
connections, I believe you will get a new connection on each iteration
through the loop...
Cheers,
- B.
--
All men know the utility of useful things;
but they do not know the utility of futility.
-- Chuang-tzu
14:29:46 up 2 days, 3:15, 2 users, load average: 0.09, 0.12, 0.19
More information about the Melbourne-pm
mailing list