my $query = "SELECT * FROM lala WHERE moomoo = ?"; my $sth = $dbh->prepare($query); # at this point, the query string is parsed, and discovers # that there is one substituion. The DBI will require one # argument to the C function and complain if it # doesn't see one. foreach my $moomoo_val ( @vals ){ # Note that the query is now cached, and can be # re-C'd as many times as you wish. $sth->execute($moomoo_val); while(my $row = $sth->fetchrow_hashref){ print( join("\t", vals %$row), "\n" ); } }