##print and insert at the same time while( my @results = $table_results->fetchrow_array()) { print join(",",@results); print "\n"; $sth_insert->execute(@results); }