in reply to Search engine code critique

Here's my suggestion; whether it's an improvement or not I'll leave up to the judgement of the XP meter :)

Where you have:

my $onlyonce = 1; foreach my $tempword ( @words ) { if ( $onlyonce == 1 ) { $searchstring .= "MajorDescription LIKE '%$tempword%' OR M +ajorName LIKE '%$tempword%'"; $onlyonce = 0; } else { $searchstring .= " OR MajorDescription LIKE '%$tempword%' +OR MajorName LIKE '%$tempword% +'"; } }
Having "almost" the same SQL code in 2 branches of an if is very hard to maintain or debug correctly, in my opinion.

Why not replace all of that with:

$searchstring=join " OR ", map "MajorDescription LIKE '\%$_\%' OR MajorName LIK +E '\%$_\%'", @words;
join and map sometimes scare folks, but I think that's more readable and less fragile than your structure.

If you don't like join/map, may I suggest this alternative?

my $or=""; foreach my $tempword ( @words ) { $searchstring .= " $or MajorDescription LIKE '%$tempword%' OR +MajorName LIKE '%$tempword%'"; # only set this once $or="OR" unless $or; }

--
Mike