in reply to perl - loop
As ELISHEVA said, welcome to the monastery.
It's probably worth pointing out how this site works. Everyone here is a volunteer. We're taking time out of our busy day to come here and offer help to people. We're not getting paid for the work we do here and we don't have to help anyone if we don't want to.
Bearing that in mind, you're far more likely to get help if you make it as easy as possible for us to help you. The harder you make it for us to help, the less likely it is that we'll bother.
Before you posted your node, you had to preview it. And underneath the preview was this text:
If something looked unlike you expected it to you might need to check out Writeup Formatting Tips
I assume that you read this message, but that you thought that your post looked fine. I can't understand that as your code is an unreadable mess. Had you bothered to click on the Writeup Formatting Tips, you would have learned that putting <code> tags around your source code would have formatted it more readably.
The fact that you didn't bother to do that will almost certainly mean that many of the most knowledgeable helpers on this site won't bother trying to understand your code and won't offer you any help.
We get a lot of people whose first post is messed up like yours. If you have any suggestions on how we can make the formatting process easier to follow, then we'd love to hear them.