I think I have discovered the problem. In my code, I did a pop(@in) just to remove the newline that occurs when the user types in the letters. This was accidentally left in your code. If you comment out line 41, everything should work fine!
The finally (maybe :-) revised code (that should do everything correctly) can be found
Hehe - ok... lets hope this hits the mark:
The correct and final code is in the above post. Yay.