in reply to Multiple references pointing to the same memory location

Here is a direct quote from Programming the Perl DBI, Decartes and Bunce, O'Reilly, Page 223 Section fetchrow_arrayref.

'Note that the same array reference will currently be returned for each fetch, don't store reference and then use it after a later fetch'

In other words you are getting a shallow copy of row array instead of the deep copy you want/need. ( of course this what you have already discovered :( ).

Why not dereference rowarray_ref and simple store and array of arrarys.

... push(@entries, [ @$colunms_ref ]); ...

Update
'Holy Flatlander Chips' bwana147 caught a my baadddd very baddd deref causing column_ref flating out. I can't claim a typo on this one folks I just plain forgot :(. thx bwana147.

In addition after a short CB discussion with davorg we reach a consensus of two that this could all be resolved by simply using fetchrow_array and avoiding all his pesky derefencing.

mitd-Made in the Dark
'My favourite colour appears to be grey.'

Replies are listed 'Best First'.
Re: Re: Multiple references pointing to the same memory location
by bwana147 (Pilgrim) on Jul 31, 2001 at 13:10 UTC

    Be careful here: the OP wanted a list of array refs, each one containing a row of data. If you push(@entries, @$columns_ref), you'll end-up with @entries being a flat list of all the columns, without any way of knowing where each row starts or ends. You really must create a new array, copy the values from the array referenced by $column_ref and push a reference to the new array. This can be done easily, as has already been pointed out:

    push(@entries, [ @$columns_ref ]);

    --bwana147