in reply to regex search

As it is your code will give an error because of the unterminated substitution. It won't create valid sql and would actually do an all keywords match only. you want to try something along the lines of
$sql_stmt = "select * from database where 1=1"; #This is how I would do the match in Postgresql #Check your DB docs for the correct syntax my $matchstring = join ' OR ', map { "PlantDescription ~ ".$dbh->quot +e($_)} @keywords; $sql_stmt .= ' AND '.$matchstring if $matchstring;