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



miniCruzer
Novice

Oct 10, 2010, 1:29 PM


Views: 4982
SQLite 'SELECT' Function

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


Views: 4981
Re: [miniCruzer] SQLite 'SELECT' Function

$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)