Guessing....
I am guessing too on this $j=$k++;
Some perlmonk taught me that push join and splitting stuff and another 1 liner to output an array to a csv file. It works everytime.![]()
Code:
push @array [split ',',[COLOR="Cyan"]join(',',@row)[/COLOR]];
If this is the case, only the highlighted part would have suffice to join the fields for a record into a line string. By calling split again, it would chop them back into pieces and pushed into @array.
Probably when we inspect some sample value of @row, then we will know why we need to join and split. Could be that some elements of @row already have commas (',') in them, and the split is to ensure those are all cut properly. The danger is that some fields may indeed hold valid values that should include commas and the simplistic splitting here would cause corruptions.
Recommended way of dealing with proper parsing and formatting of CSV is to use Text::CSV in CPAN.
