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