For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > July 2005 > how to obtain a reference to array which is returned by a function without intermedia









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author how to obtain a reference to array which is returned by a function without intermedia
Denis N.

2005-07-25, 9:24 am

here is the snippet from the code:

--------
....
my $selectHandle = $dbh->prepare(...);
....
$selectHandle->execute(....);
my @data = $selectHandle->fetchrow_array();
$self->[1] = \$data;
.....
--------

and another one:

-------
....
my $selectHandle = $dbh->prepare(...);
....
$selectHandle->execute(....);
$self->[1] = $selectHandle->fetchrow_arrayref();
....
------

The second one is not correct because it turned out that fetchrow_arrayref()
return reference to the same array (as described in man page).
Because of that objects contain the same data from the last invocation of
fetchrow_arrayref....

The first one seems to be quick and dirty solution, but involves copying an
array.
Is there a syntax for obtaining the reference to the array returned by the
function without copying it first?

--
Thanks in advance,
Denis


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com