If your files are CSV files, use Text::CSV to read/write them

P.S. Consider reading "Learning Perl" (no earlier than 4th edition) or "Beginning Perl".