http://www.perlmonks.org?node_id=27112

moo has asked for the wisdom of the Perl Monks concerning the following question:

How do I pass a database handle in DBI between subroutines?

Originally posted as a Categorized Question.

  • Comment on How do I pass a database handle in DBI between subroutines?

Replies are listed 'Best First'.
Re: How do I pass a database handle in DBI between subroutines?
by lhoward (Vicar) on Aug 09, 2000 at 21:33 UTC
    Just like you would any other object... See my example below showing passing a database handle in and out of 2 functions.
    my $dbh=bar(); foo($dbh); sub foo{ my $dbh=shift; # do something with the database handle.... } sub bar{ my $dbh=DBI->connect(...... return $dbh; }