in reply to escaping commas in value when writing to a cvs file

The first thing I looked for while reading over your code was a line such as use Text::CSV. The simplest way you can achieve what you're after is to process your CSV data using Text::CSV. Not only is it the simplest way, it's also bound to be the most robust and thoroughly tested approach.


Dave

Replies are listed 'Best First'.
Re^2: escaping commas in value when writing to a cvs file
by ibra (Novice) on Feb 16, 2012 at 17:00 UTC
    Hi Dave sorry didn't mention this I am using Text::CSV

      What I see is that in your updated code the first line of use Text::CSV; has now been added. What I don't see is you putting the module to work in your solution. The synopsis section in the POD for Text::CSV gives several workable approaches to taking an array and turning it into a CSV string.

      The void between where the synopsis leaves you and where your code wields Text::CSV to form a solution is quite small; There are only a few lines of code from the Text::CSV POD that will need to be adapted to match your specific application. That's where the fun of programming comes in.


      Dave