$sql_stmt = "select * from database where "; foreach $keyword ( @keywords ) { $sql_stmt .= " AND ( PlantDescription REGEXP "s/\$keyword/" );" }