$| = 1; print "Content-type: text/html\n\n"; # get records @results = (); $sql = "SELECT * FROM my_table"; print "
sql = $sql

\n"; $sth = $dbh->prepare($sql) or die("Could not prepare!" . $dbh->errstr); $sth->execute() or die("Could not execute!" . $dbh->errstr); print "
executed sql

\n"; $k = 0; while (@results = $sth->fetchrow_array()) { $data[$k] = [ @results ]; $k++; } $sth->finish; for $a (0 .. $#data) { print "
$a => "; for $b (0 .. $#{$data[$a]}) { print ", $data[$a][$b]"; } } print "
Done\n";