in reply to
Re^2: How to pass arrays into this program?
in thread How to pass arrays into this program?
It sounds like Text::CSV will do what you want.
Please note that the majority of the code you posted has nothing to do with your question: this just leads to confusion (and perhaps frustration) when attempting to isolate the handful of relevant lines from the two screenfuls of code you posted.
A better question will get better answers: the guidelines in "How do I post a question effectively?" can help you achieve this.