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

Re^5: Splitting a line on just commas

by deMize (Monk)
on Jun 14, 2010 at 18:17 UTC ( [id://844692]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Splitting a line on just commas
in thread Splitting a line on just commas

The proper extraction method has not been shown, Anonymous came closest, but as stated, it's still a problem. He used a 2-step method, which I think the most of us were trying to solve in one step, though using [^"]* rather than .*, is necessary.


Demize

Replies are listed 'Best First'.
Re^6: Splitting a line on just commas
by ikegami (Patriarch) on Jun 14, 2010 at 19:13 UTC

    Whoa, how did you come to think that using two steps makes it wrong. Besides, you can easily make it take one step by changing it to

    my @fields = $s =~ /("[^"]*"|[^,]*)(?:,|$)/g;

    Of course, there's still the question of values with quotes or newlines, space around the comma, etc. But yours didn't even attempt at handling any of those either.

    The proper extraction method has not been shown

    Seeing the mess that's resulting from people trying to reinvent the wheel, I'd argue I showed the proper extraction method.

Re^6: Splitting a line on just commas
by ikegami (Patriarch) on Jun 14, 2010 at 19:15 UTC
    [ Duplicate post. Please ignore.]

    Whoa, how did you come to think that using two steps makes it wrong. Besides, you can easily make it take one step by changing it to

    my @fields = $s =~ /("[^"]*"|[^,]*)(?:,|$)/g;

    Of course, there's still the question of values with quotes or newlines, space around the comma, etc. But yours didn't even attempt at handling any of those either.

    The proper extraction method has not been shown

    Seeing the mess that's resulting from people trying to reinvent the wheel, I'd argue I showed the proper extraction method.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-24 02:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found