in reply to Possible looping or syntax error

This is not valid Perl code. You have parentheses instead of curlies for your elses, and you don't have things balanced. You don't say where $search comes from, and you don't give us any notion of what input yields what output, and how that's different from what you expect.

The PerlMonk tr/// Advocate