$dbh->foreach my $cluster (@clusters) { do ("INSERT INTO $table (start, end) VALUES (cluster[0], cluster[1]);"); } # Ensure that the insertion is committed (or set auto-commit when first connecting to the DB). $dbh->commit();