title: Perl many insert statments into mysql database
body: <p>I currently have code for perl that looks like this:</p>
  
  <pre><code>@valid = grep { defined($column_mapping{ $headers[$_] }) } 0 .. $#headers;
  
  ...
  
  my $sql = sprintf 'INSERT INTO tablename ( %s ) VALUES ( %s )',
    join( ',', map { $column_mapping{$_} } @headers[@valid] ),
    join( ',', ('?') x scalar @valid);
  my $sth = $dbh-&gt;prepare($sql);
  
  ...
  
  my @row = split /,/, &lt;INPUT&gt;; 
  $sth-&gt;execute( @row[@valid] );
  </code></pre>
  
  <p><em>(Taken from <a href="https://stackoverflow.com/users/168657/mob">mob</a>'s <a href="https://stackoverflow.com/a/31842226/176646">answer</a> to a previous question.)</em></p>
  
  <p>That is basically dynamically building a sql insert statement from csv data, and only allowing the csv data with proper headers from my column mapping to be picked.</p>
  
  <p>I have been looking for examples on how to do an insert statment with multiple rows of data at once.</p>
  
  <p>My perl script needs to run around a few hundred million insert statments, and doing it one at a time seems really slow, especially since the server I am running it on only has 6gb of ram and a slowish internet connection. </p>
  
  <p>Is there a way I can upload more than 1 row at a time of data? So one insert statment uploads maybe 50 rows, or 100 rows at once? I cant find out how with perl DBI.</p>