Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: CSV and regex mixups

by flounder99 (Friar)
on Jul 03, 2003 at 11:57 UTC ( [id://271134]=note: print w/replies, xml ) Need Help??


in reply to CSV and regex mixups

It sounds to me like using Text::CSV might be a waste of time. If you get a working regex why not just use it for everything? Modules are for convenience, if you have to parse a line before handing it to a parser why bother with the parser?
Just a thought.

--

flounder

Replies are listed 'Best First'.
Re: Re: CSV and regex mixups
by flounder99 (Friar) on Jul 03, 2003 at 13:07 UTC
    I felt kind of bad just giving an opinion and not a useful suggestion so here is my suggestion:
    use strict; my $val = '"crosby","stills","nash","and sometimes "young""'; print join "\n", split /(?<="),(?=")/, $val; __OUTPUT__ "crosby" "stills" "nash" "and sometimes "young""
    This works if you know you know your fields will always be surrounded by double quotes and there will be no spaces arround the comma. The spaces could be taken care of by using the regex /(?<=")\s*,\s*(?=")/.

    --

    flounder

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-26 00:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found