Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: split on commas (Text::Balanced)

by ikegami (Patriarch)
on Jun 09, 2009 at 18:17 UTC ( [id://770040]=note: print w/replies, xml ) Need Help??


in reply to Re^2: split on commas
in thread split on commas

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>

Replies are listed 'Best First'.
Re^4: split on commas (Text::Balanced)
by pip9ball (Acolyte) on Jun 10, 2009 at 17:38 UTC
    Sorry, I apologize I didn't see this question. Yes, all I want is each token back.
    This solution seems to be working

    Thanks!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://770040]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-19 21:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found