I get downvoted whenever I mention it, but this sounds a lot like homework. So... What have you tried, where did you get stuck, what's the results you got? And if it's not homework, it seems like this is in all the Chapter Ones of any Perl book you could find.