jevaly has asked for the wisdom of the Perl Monks concerning the following question:
In a program I've got two subroutines, one of these initializes a reference to a DB connection, the other wants to use this reference through a parameter hash.
I thought someting like this would work:The first connect works fine, the second fails with error message:my %parameterhash; my $hashref = \%parameterhash; a($hashref); b($hashref); sub a{ my $hash_ref = @_; my $dbconnection= makeDBconnection(); my $handle = \$dbconnection; connect($handle); $hash_ref->{dbhandle} = $handle; } sub b{ my $hash_ref = @_; my $hand = $hash_ref->{dbhandle}; connect($hand); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: passing (hash)refs through subroutines
by wfsp (Abbot) on Nov 03, 2009 at 10:58 UTC |