Use chomp inside the loop.
In reply to Re^3: using grep to search an array by John M. Dlugosz in thread using grep to search an array by alicatserver