[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] One for the perl hackers
- Subject: [ale] One for the perl hackers
- From: fletch at phydeaux.org (Mike Fletcher)
- Date: Thu, 3 Oct 2013 19:07:23 -0400
- In-reply-to: <CAOXayVvC3=A8C9mnKNppoUGQio-o4GzBLo1xBqwYmSH-weHzXg@mail.gmail.com>
- References: <CAOXayVvC3=A8C9mnKNppoUGQio-o4GzBLo1xBqwYmSH-weHzXg@mail.gmail.com>
> On Oct 3, 2013, at 17:22, "Robert L. Harris" <robert.l.harris at gmail.com> wrote:
>
>
> *Sorry for the OT but my only perl lists have gone dark a long time ago*
>
>
> $String='component1,component2,"This is my, test string", component4';
>
> ($C1, $C2, $Str, $C4) = split(',', $String);
>
> I'm only getting "This is my" in $Str and $C4 does not contain "component4". Is there a graceful way of handling this? It's a 1 in 10000 chance it'll break but accuracy counts.
>
> Robert
Trying to handle csv (which it looks like your sample is) yourself is asking for pain. Use Text::CSV_XS from cpan which will handle most csv-y quoting the way you expect.
>
>
> --
> :wq!
> ---------------------------------------------------------------------------
> Robert L. Harris
>
> DISCLAIMER:
> These are MY OPINIONS With Dreams To Be A King,
> ALONE. I speak for First One Should Be A Man
> no-one else. - Manowar
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo