Since this does indeed smell of homework (and I'm lazy), I'll not provide a shrink wrapped solution (it is supposed to be homework after all). But have a look at pack to parse the lines and have a closer look than you have before at perlre to interpret them. Also, a book like Learning Perl or yea, even an extended stroll through this very site, will help you even more.
Good luck!
CU Robartes-
Comment on Re: Help with simplifying file parsing program?