in reply to Regex to do a smart split()

Text::CSV is nice but it doesn't work if the field is "partially" quoted.
use strict; my $line = join ",", ( '"completely quoted"', 'not quoted', 'partially "quoted"', '"completely quoted with embedded, comma"', 'partially "quoted with embedded, comma"', 'quote \'and comma, inside " single\' quote', 'single quote "and comma, inside of \' double" quote', 'last' ); my $re = qr/((?:[^"',]|"[^"]*"|'[^']*')+)/; print(">$_<\n") for $line =~ /$re/g;
outputs
>"completely quoted"< >not quoted< >partially "quoted"< >"completely quoted with embedded, comma"< >partially "quoted with embedded, comma"< >quote 'and comma, inside " single' quote< >single quote "and comma, inside of ' double" quote< >last<
it will choke on unbalanced quotes but it quick and dirty

UPDATE

it will also choke on empty fields like

one,,three

--

flounder