Crossposted to stackoverflow.
You are asking for help writing code, but have not provided any code of your own. Typically how this works is you show us how far you've been able to get on your own, and ask questions that we can answer to help you past where you are stuck.
It is generally expected that you will have done your own research to begin with. In this case, you can and should read perlintro and perlretut. Having read those you can write most if not all of the homework assignment yourself. And if you do get stuck, you will be able to show us the code you've written and where you're having trouble. I'm certain, at that point, that help will be forthcoming.