Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: split string by comma

by dd-b (Monk)
on Jan 10, 2012 at 23:40 UTC ( #947258=note: print w/replies, xml ) Need Help??


in reply to split string by comma

The problem is, it's not a string. That is, there's additional structure. The quotes apparently mean something special, including that you shouldn't split on commas within them. (This quickly raises the question of what it means if there are quotes within quotes, and how you escape quoting, and...soon you're having to work far too hard.) (This is a common situation of course; I sort of wrote about it as if I hadn't seen it before, but it's actually a staple of programming.)

You don't tell us what the actual format is; GrandFather's guess that it's a CSV seems reasonable, but it's just a guess. So, if you're lucky, there's a clear description of what the rules for this CSV format are, and the input you get will reliably follow them, and you can write something to parse that. But the rule here is that parsing is hard -- if you do anything more than the most brute-force simple kind.

If you're really lucky, your input conforms to the standard that the CSV module that was suggested supports, and you don't have to write the parsing yourself.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2020-10-25 07:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (249 votes). Check out past polls.

    Notices?