in reply to Logic Help - Output to csv

Desired output

"sku","File 1", "File 2", "File 6", "File 7" "00123","www.site.com/path/to/file/file.pdf","www.site.com/path/to/fil +e/file.pdf",, "00124","www.site.com/path/to/file/file.pdf",,"www.site.com/path/to/fi +le/file.pdf", "00125",,"www.site.com/path/to/file/file.pdf",,"www.site.com/path/to/f +ile/file.pdf"

Maybe I am just nitpicking, but I sincerely hope you do not want the spaces after the separator (", ") in the header line.

If you do, why not after the first separator? The required output as you show is extremely hard to generate and results in incorrect CSV data.

For all other advice, read haukex' answers.

For more speed, use Text::CSV_XS instead of Text::CSV.


Enjoy, Have FUN! H.Merijn

Replies are listed 'Best First'.
Re^2: Logic Help - Output to csv
by Eily (Monsignor) on Jun 08, 2020 at 12:18 UTC

    Text::CSV already calls Text::CSV_XS when available, so in most case it won't have any impact on speed, and in some other cases it will stop working altogether.