the "first", "second", "third" in the code above is probably better expressed using arrays where the numbers 0, 1, and 2 give you the first, second, or third element.
overall, I think this program could benefit from an understanding of data structures, particular array and hash references. "Advanced Perl Programming" 2nd edition was great for this. 3rd edition by Cozens is a completely different animals. So, I recommend that you read perldsc and think hard about how it's contents could improve your program.
Carter's compass: I know I'm on the right track when by deleting something, I'm adding functionality