<?xml version="1.0" encoding="windows-1252"?>
<node id="1004342" title="CSV String Split" created="2012-11-17 14:26:38" updated="2012-11-17 14:26:38">
<type id="115">
perlquestion</type>
<author id="146114">
jcleland</author>
<data>
<field name="doctext">
This doesn't seem all that complicated, but it has me stuck. Well, not stuck, I could write something complicated and accomplish the same task, but I was hoping to be more elegant... and I digress.
&lt;BR&gt;&lt;BR&gt;
I have a CSV file that I need to read and parse fields from. All values are quoted and the quoted string can contain commas. Sometimes, there are missing values in the record (line, row, whatever), these have no quotes at all (so you can have sequential commas for missing fields). Obviously, I need to split these records into fields. Here's an example of what a line might look like:
&lt;BR&gt;&lt;CODE&gt;
,"value",,"value1,value2","anothervalue","oh,comeon",,"Givemeabreak" 
&lt;/CODE&gt;
So trying to use split(',' $_); isn't going to give me what I want. Is there something fancy I can do with a split() regex? Any help is appreciated!
&lt;BR&gt;&lt;BR&gt;
James</field>
</data>
</node>
