> From: "Alec Brecher" <[EMAIL PROTECTED]>
> Date: 2005/01/10 Mon AM 09:35:16 CST

> I am trying to figure out the most efficient method of passing around a live
> dbh when calling a subs.

Contrary to what the other replies have been, my suggestion is that you just 
declare your handle with 
my %obj;

(or was suggested by someone else, and I agree, just 
my $dbh;
) 

as a global variable.  Then, it is automatically available to all subroutines.  
If you need it to be avaible to subroutines imported via require() or use(), 
then declare it as 

our %obj;
or
our $dbh;

Additionally, if you do need a copy of the handle to be used exclusively by 
some sub (for instance, so you can run a secondary query while keeping the 
results of the first query open) you can do something like:

sub foo {
  my $dbh = $obj->{$dbh}->clone();
  ...
}

  That last part may actually be "$obj->{$dbh->clone()};", I sometimes have 
problems with functions of embedded variables...  :-)

> Thank you.  -Alec

HTH,
amonotod


--

    `\|||/         amonotod@    | sun|perl|windows
      (@@)         charter.net  | sysadmin|dba
  ooO_(_)_Ooo____________________________________
  _____|_____|_____|_____|_____|_____|_____|_____|

Reply via email to