>>>>> "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.

Yes, DBI has matured since the book, but I wouldn't jump to conclusions about
the validity of the code in the book.  After all, Tim Bunce co-wrote the book,
and there's nobody on the planet who knows more about DBI.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to