You would need to replace (?) with the number of array elements e.g
$val = " ";
for( $j = 0; $j < @id;$j++)
$val .= "?,";
}
$val = substr($val,0,-1);
$query = $dbh->prepare("REPLACE INTO $tbl ($col) VALUES ($val)");
and then $query->execute(@id);
works fine (tested with DBI:mysql)