How to parse a well behaved CSV using a regex in Perl 5:
while( m{ (^|,) (?: "([^"]*)" | ([^,"]*) ) }xg) { $f = $+ $f = $^N # version 5.8 named reference }
That’s the maintainable code version. here’s how you’d probably see it out in the wild:
while(m{(^|,)(?:"([^"]*)"|([^,"]*) ) }xg){$f = $+}
Of course, the scary part is that I now understand this.