in reply to Dereferencing nested references

No, you are not storing a reference to a hash, but a ref to a ref to a hash.

The key is this:

while (my $hash_ref = $SQLBuy->fetchrow_hashref) { push @BuySellHashref, \$hash_ref; }
In there $hash_ref, as it says, contains a reference to a hash. Then you push a reference to $hash_ref (\$hash_ref) onto your array when you just want the hashref ($hash_ref). So change it to push @BuySellHashref, $hash_ref;

Looping is then

for my $hashref (@BuySellHashref) { print $hashref->{personID} . "\n"; }

Or if you kept on the same way as before then stick to ${$hashref}->{personID} like you were doing at some points.

Replies are listed 'Best First'.
Re: Re: Dereferencing nested references
by ryddler (Monk) on Jan 16, 2001 at 19:29 UTC

    No, you are not storing a reference to a hash, but a ref to a ref to a hash.

    Of course, what was I thinking? I didn't even realize what I was doing until I read and reread this line a second time. DBI was returning a reference and I didn't even blink before stuffing a ref to a ref into my hash value. repson, I bow before you with humility and respect.

    In the interest of learning, however, how would I dereference the ref to a ref that I embedded into that hash?

    ryddler