in reply to Problem pushing hashref results
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Problem pushing hashref results
by bart (Canon) on Oct 27, 2006 at 15:24 UTC |