in reply to Problem pushing hashref results

You are storing values of the fetched record into the anonymous hash using existing hash reference first and then stores it into an anonymous array. So because you declare $attrHash outside of the while block, each time you assign to $attrHash you acctually override the previous assigned values. The simple fix would be to declare $attrHash localy within the while block to make sure it is a different hash, like in the following:
... #push the data onto our results while ( my $resultRowRef = $sth->fetchrow_hashref() ) { my $attrHash; $attrHash->{OBJECT} = $resultRowRef->{'ATTRNAME'}; $attrHash->{OBJECTATTRIB} = $resultRowRef->{'ATTRNAME2'}; push (@$result, $attrHash); } ...
or, simply create it in place:
... #push the data onto our results while ( my $resultRowRef = $sth->fetchrow_hashref() ) { push (@$result, \{ OBJECT => $resultRowRef->{ATTRNAME}, OBJECTATTRIB => $resultRowRef->{ATTRNAME2} }); } ...
BR

Replies are listed 'Best First'.
Re^2: Problem pushing hashref results
by caelifer (Scribe) on Oct 26, 2006 at 17:30 UTC
    Sorry for replying to my own post. Just wanted to point out that while I wrote it, people have already posted the solutions. (Vote for davorg).