in reply to Split line with extra delim

jdtoronto has the best answer, but you appear to want more (or less ;).

One might think splitting with a regex would work, like this:

@x = split /"?,"?/, $chunk; # broken
but that still splits the quoted field.

Instead you can grab quoted fields and non-quoted fields, and process them separately. However, you quickly get into issues with escaped quotes, negative look-behinds, etc. It gets messy pretty quick, and difficult to maintain.

It's essentially parsing a complex syntax, so let a parser do it :)

-QM
--
Quantum Mechanics: The dreams stuff is made of