Reputation: 11901
I am new to perl I need some help to write my output to the last column of the csv file after some operations on a single row. I am using Text::CSV_XS module in perl. I know the statement to write to a csv file is print FH "sitepoint, 2, 7\n" ; But how to write to a specific column like 5th column ?
Upvotes: 1
Views: 3909
Reputation: 35790
From the Text::CSV
docs:
When writing CSV files with
always_quote
set, the unquoted empty field is the result of an undefined value.
Thus, if you do something like:
my @arr = ( undef, undef, undef, undef, "5th column" );
my $csv = Text::CSV->new ( { always_quote => 1 } );
open my $fh, '>', 'outfile.csv' or die $!;
$csv->print( $fh, \@arr );
...you should get an output file of the form
,,,,5th column
Upvotes: 3