question about DBI's fetchrow_arrayref()

abez abez at abez.ca
Wed Sep 4 23:28:33 CDT 2002


@$array_ref - dereferences $array_ref
for all intensive purposes @$array_ref is now @tmp_arr

[ @tmp_arr ] - copies all values of @tmp_arr into the anonymous array [ ].
For instance you could go

[ @tmp_arr, at tmp_arr ] to make a duplicated array copy.

Yes you are right, it copies the array.



On Wed, 4 Sep 2002, nkuipers wrote:

> Hello everyone,
> 
> I'm a little puzzled about what's actually going on with the following code 
> snippet (from Programming the Perl DBI, page 114):
> 
> 1 my @stash;
> 2 while ( my $array_ref = $sth->fetchrow_arrayref ) {
> 3   push @stash, [ @$array_ref ];
> 4 }
> 
> 5 foreach $array_ref ( @stash ) {
> 6   print :Row: @$array_ref\n";
> 7 }
> 
> It's line 3.  It looks like a dereferenced arrayref stored in a reference to 
> an anonymous array?  Did I get that right?  I realize what it is intended to 
> do: store a copy of the values that the original reference points to and not 
> just the reference itself.  Just wanted to make sure I understand the 
> mechanics of that line.
> 
> Thanks, hope everything is well,
> 
> Nathanael Kuipers
> 

-- 
ABeZ------------ ------- ------ - ---------- -- ------------
http://www.indexdirect.com/abez/ Abram Hindle (abez at abez.ca)
---- ------- ----------- ----------- - - ------ --------ABeZ




More information about the Victoria-pm mailing list