Your follow-up questions and sample code indicate that you are attempting a project far beyond your skill level. I strongly suggest that you get a copy of the book 'Learning Perl". Start at the beginning and do
every exercise. The ones that are easy will waste very little time. The hard ones will show you where study is required. As you study, it is as important to learn the correct Perl names for things as it is to learn the coding techniques. Of course, you can ask an occasional question here, but remember that the idea is to learn by doing it yourself.