http://www.perlmonks.org?node_id=387942

THuG has asked for the wisdom of the Perl Monks concerning the following question:

Sorry, I've tried searching, I still can't get it to work.

#!C:\Perl\bin use strict; use DBI; my $fromHost = "someServer"; my $fromDB = "someDB"; my $fromTable = "someTable"; my @fromFields = ("Field 1", "Field 2", "Field 3"); my $fromDSN = "dbi:mysqlPP:database=$fromDB;host=$fromHost"; my $dbh = DBI->connect($fromDSN, "", ""); my $drh = DBI->install_driver("mysqlPP"); my $rs = $dbh->selectall_arrayref("SELECT '" . join("','", @fromFields +) . "' FROM $fromTable"); $dbh->disconnect(); foreach my $myRow (@$rs) { print "@$myRow\n"; foreach my $myElem (@$myRow) { print "$myElem,"; } print "\n"; }

This will print the following:

Field 1 Field 2 Field 3
Field 1,Field 2,Field 3,

It will repeat these two lines for each record in the table, but it will never return any data from table. I do admit, I need to know the field names (the hardcoded part will eventually be removed, and fields can be supplied at runtime), but I need to get to the data, too. What am I doing wrong, and in which document should I've found the answer?