CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: DBI:
SQLite 'SELECT' Function

 



miniCruzer
Novice

Oct 10, 2010, 1:29 PM

Post #1 of 2 (2730 views)
SQLite 'SELECT' Function Can't Post

I've recently been playing with SQLite, and so far I can get this program to write to the database, but it can't read it right. I've done some Googling, and there've been no solutions so far.

This should be a fairly simple solution:


Code
sub dbread { 
my $all = $db->selectall_arrayref("SELECT * FROM CHANNELS;");
foreach (@$all) { print "$_\n"; }


The table channels would read like this:

Code
#chan1 
#chan2
#chan3

and so on. It returns no errors, but won't return the channel name, instead it prints out:

Code
ARRAY(0x9092080) 
ARRAY(0x90920b0)
ARRAY(0x90920e0)



FishMonger
Veteran / Moderator

Oct 10, 2010, 1:36 PM

Post #2 of 2 (2729 views)
Re: [miniCruzer] SQLite 'SELECT' Function [In reply to] Can't Post

$all is a reference to an AoA (array of arrays), which means that the value of each array element is a reference to another array.

Use Data::Dumper to output the data structure and from there you should see how to dereference it.


Code
use Data::Dumper; 
print Dumper $all;



(This post was edited by FishMonger on Oct 10, 2010, 1:36 PM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives