my $sth = $dbh_in->prepare(" INSERT INTO my_table ( name_1, name_2, name_3, name_4 ) VALUES ( ?,?,?,? ) "); $sth->execute($fields[0], $fields[1], $fields[2], $fields[3]); $sth->execute(@fields[0..3]); $sth->execute((@fields, undef, undef, undef, undef)[0..3]); #### my $sth = $dbh_in->prepare(" INSERT INTO my_table ( " . join(', ', map 'name_'.$_, 1..@fields) ." ) VALUES ( " . join(',', ('?') x @fields) ." ) "); $sth->execute(@fields);