OK. It is homework, but some general comments on coding:
Good luck with the coding.
PS. Where I refer to 'perlvar', 'perlre' etc, these are some of the standard documentation which comes with perl. On Windows with Activestate perl, you can often find this in HTML format on the Start button/Programs/Activeperl, and on all systems you can type "perldoc perlvar" (or whatever) at a command prompt and get the information.