Quoted every word that is not already quoted is rather tough problem. Here is a trivial solution:
but this only handle words, no digits. Also, what if there is one quote present? or something like this:$word = qq("$word") if $word !~ /"/;
Gets rather sticky, which brings me to your next question, How to determine the delimiter being used? Well, there is no solution for that - partial solutions, maybe - but i would use my own eyes for that solution.foo,hello""world,bar
Ever hear the one about about the $600 pen delevoped for space. It was painstakenly and expensively designed to work in zero gravity and extreme temperatures. The Russians used a pencil! :D
Lesson here, some things are quicker done by brute force.
Last question, how to pull out each word? Read the docs for one the CPAN modules mentioned above. There have been LOTS of questions asked on this site about parsing CSV files. Try super search on this site. i won't show you code, because i would just be copying the docs, but i will explain the process.
Basically, you open the file and read it one line at a time or slurp it into an array and process the lines that way (hint: while loop). Then you pass each line to a method provided by one of the CPAN modules mentioned above, and you get back a list of parsed scalars. You process those one at a time (hint: for loop) and determine if you need to add quotes or not (hint: regex).
What to do from there you never specfied, i would imagine the most usefull thing to do would be to save it back to another file.
jeffa
In reply to (jeffa) Re: Quoting words
by jeffa
in thread Quoting words
by ellem
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |