in reply to Re: Re: Re: Code factory
in thread Code factory

If I recall correctly, DBI recycles the hash reference with each iteration. What you end up with is an ARRAY of exactly the same HASH data. You should duplicate it, as was done with that first bit of code, or better yet:
push(@$results, { %$row });

Replies are listed 'Best First'.
Re: Re: Code factory
by Notromda (Pilgrim) on Jul 09, 2003 at 01:55 UTC
    No, it does a new hashref every time. At least, this works for me:
    my @result; while (my $row = $sth->fetchrow_hashref()) { push @result, $row; }
Re: Re: Code factory
by duct_tape (Hermit) on Aug 26, 2003 at 20:03 UTC

    This is a late response since I tend to not pay attention too often.

    DBI recycles arrayref's, but not hashref's. It may be good to make a copy of the hashref just in case that changes in the future though....