in reply to Re: split on commas (Parse::RecDescent)
in thread split on commas

Wow, thanks for your in depth reply! I can see how this can be very powerful but I'm afraid I don't understand
the ParseRec module well enough to expand on the grammar.

I'll see if I can read up on the module :-)

Thanks again!

Replies are listed 'Best First'.
Re^3: split on commas (Text::Balanced)
by ikegami (Patriarch) on Jun 09, 2009 at 18:17 UTC
    You still didn't specify what data you need from the line. If you really just want to split on the commans, you can use Text::Balanced.
    use strict; use warnings; use Text::Balanced qw( extract_bracketed extract_multiple ); while (<DATA>) { chomp; print("\n") if $. != 1; my @extracted = extract_multiple($_, [ ',', \&extract_bracketed, ]); my @pieces; push @pieces, '' if @extracted; for (@extracted) { if ($_ eq ',') { push @pieces, ''; } else { $pieces[-1] .= $_; } } print("$_\n") for @pieces; } __DATA__ <*2>FOO<2,1>,<*3>(SigB<8:0:2>,BAR),<*2>Siga<2:0>,Sigb<8,7,6,5,0>
      Sorry, I apologize I didn't see this question. Yes, all I want is each token back.
      This solution seems to be working

      Thanks!