my $sth = $dbh->prepare("DELETE * FROM table WHERE message_id = ?"); while $i (@MESSAGE_IDS){ $sth->bind($i) $sth->execute(); # and so on ... }