# prepare the SQL my $sth = $dbh->prepare('select * from table'); # execute $sth->execute(); # fetch first row my @row = $sth->fetchrow_array(); # print remaining rows while (my @row = $sth->fetch_array()) { print join(',', @row), "\n"; }