open FH, '<', "$filename.csv" or die("Can't open $filename.csv"); $dbh->begin_work; my $sth = $dbh->prepare("INSERT INTO T_$filename (".join(', ',@column). ") VALUES (".join(',',map{'?'} @column).")"; my $c_size = 500; #size of buffer chunk my @buffer; while () { my @row = split(','); #No quoting issues in these files, yay! push @buffer, \@row; next unless (@buffer >= $c_size or eof(FH)); while (@buffer) { my $row = shift @buffer; $sth->execute(@$row); } } close FH; $dbh->commit;