123456
Prototype
"Number in address is 100. Please, check your records."
... so Text::CSV escapes the value that has spaces (the default setting) using the default escape character, which is ... a double quote mark.
But it's only happening because of how you are assembling the value (use sprintf) or because you are trying to quote the comma. Just let Text::CSV handle it:
$ perl -Mstrict -MText::CSV=csv -wE 'my $num = 100; csv(in => [["12345
+65", "Prototype", "Number in address is $num. Please, Please check yo
+ur records.", "foo bar", "baz,qux"]], out => *STDOUT)'
1234565,Prototype,"Number in address is 100. Please, Please check your
+ records.","foo bar","baz,qux"
Note 'foo bar' quoted because it contains a space; 'baz,qux' quoted because it contains the field separator character.
Change the separator character:
$ perl -Mstrict -MText::CSV=csv -wE 'my $num = 100; csv(in => [["12345
+65", "Prototype", "Number in address is $num. Please, Please check yo
+ur records.", "foo bar", "baz,qux"]], out => *STDOUT, sep_char => "|"
+)'
1234565|Prototype|"Number in address is 100. Please, Please check your
+ records."|"foo bar"|baz,qux
Note 'baz,qux' not quoted because does not contain the separator character, 'but 'foo bar' and your string still quoted because they contain spaces.
Also turn off quoting of values with spaces:
$ perl -Mstrict -MText::CSV=csv -wE 'my $num = 100; csv(in => [["12345
+65", "Prototype", "Number in address is $num. Please, Please check yo
+ur records.", "foo bar", "baz,qux"]], out => *STDOUT, sep_char => "|"
+, quote_space => 0)'
1234565|Prototype|Number in address is 100. Please, Please check your
+records.|foo bar|baz,qux
Note no quoting even where values have spaces (not recommended).
Hope this helps!
The way forward always starts with a minimal test.
|