Your re-using the same $attrHash variable each time, so you just overwrite the values on each iteration.
You need to create a new instance of the variable each time round the loop.
while (my $resultRowRef = $sth->fetchrow_hashref) { my $attrHash; $attrHash->{OBJECT} = $resultRowRef->{ATTRNAME}; $attrHash->{OBJECTATTRIB} = $resultRowRef->{ATTRNAME2}; push @$result, $attrHash; }
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
In reply to Re: Problem pushing hashref results
by davorg
in thread Problem pushing hashref results
by rashley
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |