[ale] One for the perl hackers

Jim Kinney jim.kinney at gmail.com
Thu Oct 3 18:08:09 EDT 2013


Unless you have a magical way to escape the comma inside the quoted string,
you're stuck. sed 's/\(".\+\),\(.\+"\)/\1\\,\2/g' file. Assuming all
intermediate strings will be double quoted.

Might try splitting to an array instead of individual string vars. Then you
can do a length test to see if you got something "extra".
@strings = split(',' , $String);

Be sure to empty the array after each run or loop it as a local variable
created each pass.



On Thu, Oct 3, 2013 at 5:22 PM, 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
>
>
> --
> :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
>
>


-- 
-- 
James P. Kinney III
*
*Every time you stop a school, you will have to build a jail. What you gain
at one end you lose at the other. It's like feeding a dog on his own tail.
It won't fatten the dog.
- Speech 11/23/1900 Mark Twain
*
http://heretothereideas.blogspot.com/
*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.ale.org/pipermail/ale/attachments/20131003/54f73ba9/attachment.html>


More information about the Ale mailing list