|Perl Monk, Perl Meditation|
generating csv fileby Anonymous Monk
|on Feb 02, 2012 at 21:27 UTC||Need Help??|
Anonymous Monk has asked for the
wisdom of the Perl Monks concerning the following question:
I have been using the Text::CSV module to read csv files and now come to the part where I need to generate a revised csv file, and am confused how to do that.
I am fine if I want to keep the whole row:
but I am confused when I need to modify the '@rows', ie remove some of the columns(fields) or add some new fields on to it.
I am sorry for the basic question, but I am doing some volunteer work for a theatre trying to move from one system to another, and after being away from coding for 8 years, I have forgotten it all!
I think I understand that '@rows' just isn't an array, as I have been accessing the columns by the syntax of $row->2, but now I don't know how to create the structure that the csv writer needs. It wants an array ref and I am lost!
The three things I need to do are:
1. Only use (out of 20 cols, columns 1-10,12,15).
2. Modify the value of col 1 by prefixing the character 'r'
3. Add a new column to each row as i parse it, with a string value for its content.
If I could get help so i can proceed, I would be very thankful. I have read and reread the perl docs on the module but am still lost.