in reply to Hash references moving between modules
$cvterm_id is a scalar with no content at the beginning.my $cvterm_id; # this scalar is going to be a hashref while (my $hashref = $sth->fetchrow_hashref) { $$cvterm_id{$$hashref{termname}} = $$hashref{cvterm_id}; }
If $cvterm_id is going to be a hash reference, you need to use it like this:
If $hashref is also a real hash reference and not just the name of a hash, then you need this:my $cvterm_id; # this scalar is going to be a hashref while (my $hashref = $sth->fetchrow_hashref) { $cvterm_id->{$$hashref{termname}} = $$hashref{cvterm_id}; }
Then the second package should work.my $cvterm_id; # this scalar is going to be a hashref while (my $hashref = $sth->fetchrow_hashref) { $cvterm_id->{$hashref->{termname}} = $hashref->{cvterm_id}; }
Try looking at the contents of $cvterm_id in the second package after the while loop, using Data::Dumper for instance. (use Data::Dumper; print Dumper($cvterm_id);)
I hope that helps,
C.
PS: Dereferencing references using the arrow operator is explained on page 253 of the Camel book (3rd edition)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Hash references moving between modules
by scain (Curate) on Jan 10, 2003 at 18:47 UTC | |
by castaway (Parson) on Jan 14, 2003 at 14:39 UTC |