#!/usr/bin/perl -w use strict; use Text::CSV_XS; my @data = ( ["Hello,\nworld" ], ["One\nTwo\nThree"], ); my $csv = Text::CSV_XS->new({binary => 1}); open CSV, "> example.csv" or die "Couldn't open file. $!\n"; binmode CSV; for my $aref (@data) { $csv->combine(@$aref); print CSV $csv->string(), "\r\n"; } #### #!/usr/bin/perl -w use strict; use Spreadsheet::WriteExcel; my $workbook = Spreadsheet::WriteExcel->new('example.xls'); my $worksheet = $workbook->add_worksheet(); my $format = $workbook->add_format(text_wrap => 1); $worksheet->write('A1', "Hello\nWorld", $format);