I'm reading an Excel .csv file. Fields are separated by commas. If a field contains a comma, the whole field is double-quoted (Excel does this by default). An example of an input line is as follows:
field1,field2,"field3a, field3b, field3c",field4,"field5a, field5c",field6 I want to get each field into an array. Quoted fields should be in one element, containing commas, but without quotes. Code so far is shown below. It's a bit messy. Anyone have a better way? Thanks in advance, Dave # Note: $_ contains the whole (chomped) line at this point while (m/,"(.*?)",/) { $a = $`; $b = $'; ($m = $1) =~ s/,/¬/g; # Just use some temporary character other than a comma $_ = $a.",".$m.",".$b; } @arr = split(","); foreach (@arr) {s/¬/,/g;} # Done -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]