Lets say I have a database handle object, $dbh. Now I
want to pass it to another subroutine like:
backup(dbh=>$dbh);
sub backup
{
my (%arg) = @_;
my $sth = $arg{"dbh"}->prepare(some SQL);
my $rc = $sth->execute();
}
Now this works, but shouldn't I be passing a reference
to the object, and then unreferencing it in the sub
routine?
I tried:
backup (dbh=>\$dbh);
sub backup
{
my (%arg) = @_;
my $dbh = \$arg{"dbh"};
my $sth = $dbh->prepare(some SQL);
my $rc = $sth->execute();
}
But that didn't work. Maybe this is all stupid
because I think $dbh is just a pointer to an object,
and so passing by value just gives me another pointer
to an object.
Jay
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/