Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: split on comma-separated fields, where a field may have commas inside quotes

by CountZero (Bishop)
on Jun 10, 2009 at 18:33 UTC ( [id://770418]=note: print w/replies, xml ) Need Help??


in reply to Re^2: split on comma-separated fields, where a field may have commas inside quotes
in thread split on comma-separated fields, where a field may have commas inside quotes

But the first asterisk yields empty chunks
grep will solve that problem easily:
@chunks = grep {$_} ($str =~ /[^,"]*(?:"[^"]*"[^,"]*)*/g);

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-04-25 10:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found