..but I want to do it in Perl
Hi,
As addendum to the above perfectly fine responses, i would also like to suggest you come up with a loose design for this solution
If its just a P.o.C to test your Perl skills,its always good to start from scratch reading thru the links mentioned by the monks, focusing on File I/O operations, a great way to start learning perl.
Please search on PM,or see this post How to combine multiple files together if you want industry grade program alternatives, though through the years, you will find, *there's more than one way to do it*.
The Great Programmer is one who inspires others to code, not just one who writes great code