On Thu, 11 Mar 2004, Perrin Harkins wrote: > Skylos was guessing you had closure problems from doing this. However, > if these are always globals, you will not get closures from this. What > you need to look for is some place where you are either using $dbstr and > friends as lexicals (my $dbstr), or referring to a $dbh that was defined > outside of the sub you're using it in, e.g. > > my $dbh = DBI->connect($dbstr,$dbuser,$dbpass); > > sub foo { > my $x = $dbh->prepare.... > }
He did say that, didn't he? That he has all sorts of subroutines and relies on these global variables to provide himself the connection. > As Skylos also pointed out, a common approach for handling these things > is to have a singleton class. If that sounds too confusingly OO for > you, just think of a simple utility function that you always call to get > a $dbh: > > package ORS::DBUtil; > use strict; > use warnings; > use Apache; > > sub get_dbh { > my $r = Apache->request; > my $dbstr = $r->dir_config('DBASE'); > my $dbuser = $r->dir_config('DBUSER'); > my $dbpass = $r->dir_config('DBPASS'); > return DBI->connect($dbstr,$dbuser,$dbpass); > } > > # elsewhere... > my $dbh = ORS::DBUtil::get_dbh(); Bravo, I like that example. If only I could be so clear always. Skylos - [EMAIL PROTECTED] - The best part about the internet is nobody knows you're a dog. (Peter Stiener, The New Yorker, July 5, 1993) - Dogs like... TRUCKS! (Nissan commercial, 1996) - PGP key: http://dogpawz.com/skylos/mykey.asc -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html