<div dir="ltr"><div><br></div><div>That worked perfectly, Thank you.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Oct 3, 2013 at 4:42 PM, Larry Leszczynski <span dir="ltr"><<a href="mailto:larryl@emailplus.org" target="_blank">larryl@emailplus.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Robert -<br>
<div class="im"><br>
> $String='component1,component2,"This is my, test string", component4';<br>
><br>
> ($C1, $C2, $Str, $C4) = split(',', $String);<br>
><br>
> I'm only getting "This is my" in $Str and $C4 does not contain<br>
> "component4". Is there a graceful way of handling this?<br>
<br>
</div>It's doing what you asked, namely splitting on any comma it finds - it<br>
does not know that<br>
you do not want it to split in the middle of a double-quoted string...<br>
<br>
That line looks like a line you would get in a CSV file, so I would<br>
handle it that way:<br>
<br>
use Text::CSV;<br>
<br>
my $line = 'component1,component2,"This is my, test string",<br>
component4';<br>
<br>
my $csv = Text::CSV->new;<br>
<br>
$csv->parse($line) or die $csv->error_diag();<br>
<br>
my @columns = $csv->fields();<br>
<br>
At this point, @columns contains:<br>
<br>
$columns[0]: 'component1'<br>
$columns[1]: 'component2'<br>
$columns[2]: 'This is my, test string'<br>
$columns[3]: ' component4'<br>
<br>
HTH,<br>
Larry<br>
_______________________________________________<br>
Denver-pm mailing list<br>
<a href="mailto:Denver-pm@pm.org">Denver-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/denver-pm" target="_blank">http://mail.pm.org/mailman/listinfo/denver-pm</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>:wq!<br>---------------------------------------------------------------------------<br>Robert L. Harris<br><br>DISCLAIMER:<br> These are MY OPINIONS With Dreams To Be A King,<br>
ALONE. I speak for First One Should Be A Man<br> no-one else. - Manowar
</div>