in reply to Re: problems returning from recursive subroutine
in thread problems returning from recursive subroutine
The thing that bit me regarding this (because I always used to work with implicit closes) was prepare_cached(). The following snippet, within a function that's called repeatedly, will not work as expected:
The second time you do that DB statement, using prepare_cached() and not having called finish(), you will have a DBI error. Thus, I explcitly close all external things, but implicitly close all internal things.sub oft-used_func { .... if ($do_db_call) { my $sth = $dbh->prepare_cached($sql) || die; $sth->execute(@bind_vars) || die; while ($sth->fetch) { .... } # Use implicit close here # $sth->finish; } .... }
------
We are the carpenters and bricklayers of the Information Age.
Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.
Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: problems returning from recursive subroutine
by Abigail-II (Bishop) on Apr 18, 2003 at 15:33 UTC | |
by BrowserUk (Patriarch) on Apr 18, 2003 at 15:38 UTC | |
|
Re^6: problems returning from recursive subroutine (dbi handle != dir/file handle)
by Aristotle (Chancellor) on Apr 18, 2003 at 15:19 UTC |