The solution is that you debug your program using the advice and links already provided in reply to your several posts. If you're unable or unwilling to do so consider speaking to your manager or team leader explaining the situation. Consider the code you've actually written, what it does and what you're attempting to do. Your "expected output" does not occur within your program. http://learn.perl.org, tutorials.
I find this hard to believe given the amount of information under http://learn.perl.org alone, never mind the other links provided. Simply looking at web pages isn't going to help. This is a learning process. Consider the alternative of discussing your issue with your manager/team leader.