in reply to infinite loop on while (@array)

Only if you plan on destroying the array in the process, as in this loops as long as scalar @array > 1

You might want to reconsider for and foreach, or better yet try to give a more thorough explanation of why you believe you cannot use them.

--
perl -pe "s/\b;([st])/'\1/mg"