Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Issue parsing CSV into hashes?

by BioLion (Curate)
on Sep 21, 2010 at 17:37 UTC ( #861123=note: print w/ replies, xml ) Need Help??


in reply to Issue parsing CSV into hashes?

I agree with dasgar - you are only doing one split! Either do it as dasgar suggests, or keep it simple and just use split:

DB<5> $s = q/"foo:bar","test:boing!","whirrr:clunk"/; DB<6> %hsh = split /[:,]/, $s; ## do both the required splits in one + step DB<7> x %hsh 0 '"whirrr' 1 'clunk"' 2 '"foo' 3 'bar"' 4 '"test' 5 'boing!"'

Admittedly this test will be caught out by delimiters inside the quotes and spaces between the key/val pairs, but it is a start as to how this problem could be solved... TIMTOWTDI!

Just a something something...


Comment on Re: Issue parsing CSV into hashes?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2015-07-02 00:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (25 votes), past polls