foreach my $word (@words) { my $sth = $dbh->prepare( "SELECT * FROM my_table WHERE description LIKE '?' OR shortdescription LIKE '?' OR name LIKE '?'" ) || die "Error: " . $dbh->errstr; #append and prepend percentage signs $word ="%".$word."%" ; $sth->execute($word,$word,$word) || die "Error: " . $dbh->errstr; # do some stuff }