in reply to CSV file
my @combined = (); my ($col1, $col2, $col3, $col4) = ''; while (@array1) { $col1 = shift @array1; chomp $col1; $col1=~s/,/\,/g; #escape commas $col2 = shift @array2; chomp $col2; $col2=~s/,/\,/g; $col3 = shift @array3; chomp $col3; $col3=~s/,/\,/g; $col4 = shift @array4; chomp $col4; $col4=~s/,/\,/g; push @combined, "$col1,$col2,$col3,$col4\n"; } open OUTPUT, ">$target_file" or die "Cannot open target file! $! \n\n +"; print OUTPUT @combined; close OUTPUT;
Blessings,
~Polyglot~
UPDATE: Edited for more correct CSV style...I was thinking of "columns" instead of "commas" for some reason.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: CSV file
by dorward (Curate) on May 20, 2009 at 14:37 UTC | |
by Polyglot (Chaplain) on May 20, 2009 at 15:54 UTC | |
by raghu_shekar (Novice) on May 21, 2009 at 04:40 UTC |