How can I read individual letters of each element to ascertain what is is?
and
How can I tell if the first letter is x, or y?
Those sound like 2 different requirements to me. One quite simple, the other slightly more complex...
1. What are you actually aiming to do?
2. And what does your @foo array actually contain?
Right now, your question is just another
XY Problem (pardon the pun)