use DBI; ... my $dbh = DBI->connect($dsn, $usr, $pwd, \%attr); my $stm = 'SELECT FROM '; my $sth = $dbh->prepare($stm); $sth->execute; while (my $row_of_data = $sth->fetchrow_arrayref) { ...process data, ie, append each row to variable... } ... __END__