You asked this yesterday: Perl Loops
You were provided with substantial help including actual code and links to relevant documentation.
You appear to have made little or no effort to either read the documentation or attempt any coding yourself.
This is your homework. You should do it yourself. You'll learn nothing if someone else does it for you.
Please try to do this yourself. If you get stuck, show code that you have written along with any output (including errors messages) and ask a specific question about whatever problem you have encountered.