how to handle commas that belong in the data value
If quotes are used to disambiguate, it's fairly easy to parse with a regex:
local $_ = q(one, two, "three, four", five, six); my @words = m( \s* # gobble any leading whitespace ( # capture either: "[^"]+" # a group of quoted letters | # or [^,]+ # a group of non-quoted letters, except commas ) (?:,|$) # anchor the match to a comma, or end of string )gx;
Of course, that suffers from other problems, such as going all wonky with unbalanced quotes. But it's a fairly simple way to parse well-formed data, and I thought it might be helpful for some to look at.
In reply to Re: Re: Re: Comma separated list into a hash
by revdiablo
in thread Comma separated list into a hash
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |