Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: use of DBI perl function fetchall_arrayref

by imp (Priest)
on Jan 25, 2007 at 22:18 UTC ( #596641=note: print w/ replies, xml ) Need Help??


in reply to use of DBI perl function fetchall_arrayref

You were close.

# Create an anonymous arrayref my $arrayref = [1,2,3]; # Create a reference to an existing array my @array = (1,2,3); my $arrayref2 = \@array; # Get a single value from the arrayref: my $one = $arrayref2->[0]; # Get all the values from the arrayref: my ($one,$two,$three) = @$arrayref2;
In the code you posted you wrote:
[$sql_return]
Which is putting the arrayref provided by DBI inside another arrayref. Instead do this:
@$sql_return
It might help you visualize the data structure if you use Data::Dumper, like this:
use Data::Dumper; #... my $sql_return = $sth_tss->fetchall_arrayref; print Dumper $sql_return;


Comment on Re: use of DBI perl function fetchall_arrayref
Select or Download Code
Re^2: use of DBI perl function fetchall_arrayref
by EvanK (Chaplain) on Jan 26, 2007 at 15:24 UTC
    and if you want to be explicit in dereferencing, enclose the references in braces. this sometimes helps increase readability:
    # dereferencing an array print @$reference; # EXPLICITLY dereferencing an array print @{$reference};

    __________
    The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.
    - Terry Pratchett

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://596641]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (12)
As of 2014-07-25 16:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (174 votes), past polls