in reply to Is there any regex limitation?

What limitation are you talking about? Use split
my @fudge = split /,/, $_
Or a better idea is to use Text::CSV or Text::xSV

Replies are listed 'Best First'.
Re^2: Is there any regex limitation?
by Jim (Curate) on Jul 24, 2011 at 16:34 UTC

    You can't use split to parse CSV records—at least not the general form of CSV records represented in benlaw's example. It won't work.

      You can't use split to parse CSV records—at least not the general form of CSV records represented in benlaw's example. It won't work.

      Actually yes you can

      Using split as I've shown is as-good as benlaws intended solution, with the benefit of no backtracking

      But its a solved problem, so Text::CSV or Text::xSV

        Actually yes you can

        No. You cannot. Some of the fields contain embedded commas.

Re^2: Is there any regex limitation?
by davido (Cardinal) on Jul 24, 2011 at 22:59 UTC

    How does the split solution you posted handle the following portion of the OP's input?

    "Wah Woo, Section A"

    I can tell you how it does: One field gets ("Wah Woo), the next field gets ( Section A"), and the embedded but significant comma gets gobbled up. Or to put it simply: It handles it wrong.

    () parens added to disambiguate whitespace in the example output


    Dave

      How does the split solution you posted handle the following portion of the OP's input?

      obviously it doesn't -- just like the OPs actual code

      use Text::CSV or Text::xSV