http://qs321.pair.com?node_id=650450


in reply to Interpolating a string into list context.

The simple solution would be to split on comma, then strip quotes on each resulting value. However, I suspect you really want to ignore commas inside quotes, and escaped quotes. This becomes less trivial.

Text::Balanced has some general-purpose parsing routines for extracting quoted text. Regexp::Common has some regexes for matching quoted text, while handling escaped quotes. You would then have to write your own little parser to keep applying the regex.

I realize you asked to do this without the aid of modules. However, the task is much easier with one of these, and for non-trivial cases reinventing your own wheel is not advisable.

  • Comment on Re: Interpolating a string into list context.