in reply to array testing
I'm afraid you aren't really clear about what the problem is.
The only thing that's wrong with your demo code is declaring $test should occur before the comdition, rather than inside the then block.
You can check the array for elements, the way you do above. Sometimes it's simpler to do the join without checking the array: empty arrays generate an empty string.
--
TTTATCGGTCGTTATATAGATGTTTGCA
|
|---|