Markup in the Monastery
Code tags and formatting will help make your posts clearer.
Try stripping the code down to the bare minimum that will still cause the issue, and most of the time the problem will become obvious. And, even when it doesn't, you will have a nice short chunk of code you can post here where the problem should hopefully be obvious to at least one monk in the crowd.
Debugging without code is like performing surgery while blindfolded. But I will take a stab in the dark, and guess that perhaps you are execing the teraterm app, and thus blowing away your perl interpreter?