PerlMonks is not a code writing service. You will get more help <update>(although it looks like you have been provided with solutions as I was writing this)</update> if you show what you have tried, problems you experience, errors or warnings that you receive, desired output, and actual output.
Like other educational endeavors in life, you will get more out of it if you put more into it. In the process of describing your issue, you may stumble across some questions or ideas that give you an insight to help you resolve the problem on your own. This is not to say that you won't get help here, just that experience can be an excellent teacher. Walking through problem is a skill that can prove to be very valuable in other areas in life.