my $sth = $dbh->prepare(qq{INSERT INTO $table (col1, col2) VALUES (?, ?)}); for (@values) { # do something with the values my $affected = $sth->execute (@$_); }