my $sth = $dbh->prepare("INSERT INTO ques(username, userque, ...) VALUES (?, ?, ...)"); foreach my $t (split '~', $txtque){ $sth->execute($usernamenow, $t, ...); }