On Aug 18, 10:03 pm, [EMAIL PROTECTED] (Randal L. Schwartz) wrote: > >>>>> "Paul" == Paul Lalli <[EMAIL PROTECTED]> writes: > >> while ($array_ref = $sth1->fetchrow_arrayref) { > >> push @stash, [ @$array_ref ]; ##copy array contents > > Paul> Is that seriously from the book? UGH. Just declare $array_ref in the > Paul> proper scope, and there's no need to take a reference to a dereference > Paul> of the reference. > > Yes there is. > > Paul> while (my $array_ref = $sth1->fetchrow_arrayref) { > Paul> push @stash, $array_ref; > Paul> } > > Your code breaks on older versions of DBI, for which the book was written. > In older versions of DBI, the value of $array_ref would have been > the same for each row returned. There was this clause in "perldoc DBI": > > Note that the same array reference is returned for each fetch, so don't > store the reference and then use it after a later fetch. Also, the elements > of the array are also reused for each row, so take care if you want to take > a reference to an element.
Yeesh. I guess I'm fortunate to have only dealt with newer versions of DBI.pm. :-) Thanks for the history lesson. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/