in reply to Multi @array searches
Those two solutions differ quite a bit. Something closer to the original would be:
$terms =~ s/^\s*//; $terms =~ s/\s*$//; $terms =~ s/\s+/|/g; [download]
Of course, if you can guarantee that the input has no lead, trailing, nor repeated spaces (and no zero-width terms), then your solution would work.