in reply to Re^2: Building a dynamic array or some other method?
in thread Building a dynamic array or some other method?

I'm not sure what it is that you're doing which has resulted in abnormal operation but here it is as an SSCCE.

#!/usr/bin/env perl use strict; use warnings; use Text::CSV_XS; my $csv = Text::CSV_XS->new; my $line = '10.15.106.71,"/ifs/PH01/PH01SUB/ENTNASIS02/PH02/SMB/Share/Share6/Em +ployee-Share/Contracts/Privacy and Disclosure/Disclosure Unit/Active +Contracts/County/Sample County/E00526, E00595 Sample County DA/2017- +2020 M4385566/Emails & Correspondence/Welcome Letter.doc",FMRWX,Creat +or Owner,\ifs\PH01\PH01SUB\ENTNASIS02\PH02\SMB\Share\Share6\Employee- +Share\Contracts,This folder only,Abstract\Creator Owner,"US PII (1/1) +,Document Passwords - 2.0 (1/1),US Social Security Number (1/1),GLBA +(Gramm-Leach Bliley Act) (1/1)","Credentials (1),Financial (1),PII (2 +)",4'; $csv->parse ($line); my @fields = $csv->fields; print "Input:\n$line\n\nOutput:\n" . join "\n\n", @fields;

This outputs the parsed fields separated by empty lines so it should be trivial to see what is contained in each field. The quote characters are honoured as expected. HTH.


🦛

Replies are listed 'Best First'.
Re^4: Building a dynamic array or some other method?
by CAdood (Acolyte) on May 03, 2024 at 21:36 UTC
    In an example previously submitted, I had a large file with multiple lines, with condensing many lines containing the same access privileges on a file being condensed.

    The_DJ posted an option to slurp in an entire file into an array of arrays.

    I took that example and in processing my file, it wasn't handling quoted fields in the original file that had commas within the quoted fields.

    Perhaps in only showing one line of data, with an example, it made it sound easy to solve within a single line.

    I thought that in slurping in an entire file, there was a mode I could properly switch to for handling the quoted fields (with embedded commas). I wasn't able to figure it out, and was asking if I was misunderstanding the documentation.