[Denver-pm] Text::CSV not parsing embedded commas?

Robert L. Harris robert.l.harris at gmail.com
Wed Jul 2 11:50:13 PDT 2014


So I found out WHY the idiot put the ' $_ =~ s/"//;' in the script.  I
still get to beat him for doing it without telling us, but the 'why' is
legitimate.

Change the value of $_ to this:

$_=  file1,field2,field3,"more text, in this field 4,field5,field6

( Field 4 generaly contains user input which is quoted, but it is
truncated.  If the user input is > than that fiels will be missing the
final closing quotes. )

Now I have no idea how to compensate for that.

Robert







On Tue, Jul 1, 2014 at 12:26 PM, Robert L. Harris <robert.l.harris at gmail.com
> wrote:

>
> Given this line:
>
> $_=  file1,field2,field3,"more text, in this field 4",field5,field6
>
> I would expect the output of ( $va1, $var2, $var3, $var4, $var5, $var6
> )=$csv->fields(); to yield:
>
> $var1=field1
> $var2=field2
> $var3=field3
> $var4="more text, in this field 4"
> $var5=field5
> $var6=field6
>
> Instead though I get
>
> $var1=field1
> $var2=field2
> $var3=field3
> $var4="more text
> $var5= in this field 4"
> $var6=field5
>
> What am I missing?
>
> 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
>



-- 
: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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/denver-pm/attachments/20140702/58e52cef/attachment-0001.html>


More information about the Denver-pm mailing list