in reply to Write in files
Have a look at Text::CSV, and then once you've read through its documentation feel free to follow up with questions that remain unanswered.
Dave