in reply to One-line CSV Parser
No escaping:
$line = 'bob,"I said \"foo\"",bar';Could be shorter (matches identically):
@fields = map { /^"\s*(.*?)\s*"$/ ? $1 : split /\s*,\s*/ } split /,*("[^"]*"),*/, $lineUpdate: This too:
$line = 'bob,I said "foo",bar'I originally had the following, which shows a trick for putting multiple things in a ?: operation:
@fields = map { /^".*"$/ ? do{s/\s*"\s*//g; $_} : split(/\s*,\s*/) } split /,*("[^"]*"),*/, $lineUpdate 2: Hmm, that's what I get for not reading the RFC, non-counterexamples (counter-counterexamples?) (see other posts below)
Good Day,
Dean
|
|---|