in reply to CSV file

Text::CSV will help you.

As to writing arrays to files: open, join and print are your friends. See also perlintro.