in reply to parsing a field

While this obviously lends itself to a CSV module, wouldn't it be considerably simpler just to use split?

my @lines; while (<FILE>) { my @fields = (split /,/, $line)[1,2,3,4,5,9,11,12,13,15,16,17,18,1 +9,20,21,22,23,24]; for (0..$#fields) { $fields[$_] = qq("$fields[$_]") unless /^"[^"]*"$/; } push @lines, @fields; }

Lastly, verify your column numbers -- I passed your input line through `cut -d, -f1,2,3,4,5,9,11,12,13,15,16,17,18,19,20,21,22,23,24` and I don't seem to recall seeing the address, even after adjusting the index by removing Map,:

Axxxx,F,Bxxxx,BXXXX Axxxx,000000,NOTE:XXXXX Xxxxx (000000)@EX%SMTP:xxxxx.xxxxx@xx.com%X400:c=CA;a=;p=XX;o=xxxxxxxxxxxxx;s=XXXXX;g=Xxxxx;,Customer Srv Centre,WORKS/ SRV,SUPPORT/ SUPPORT, + 0000,(000) 000-0000 +,(000) 000-000,,,666 Snowball Paves,Vancouver,ON,CAN,J7G 3Y4

I ran another for verification:

Waaaaaa,,Lbbbbbbbb,Lccccccc Wddddddddddd,555555,SMTP:eeeeeee.fffffff@gggg.tld%HHHHHHH Iiiiiii@EX%X400:c=JJ;a=;p=KK;o=LL;s=Mmmmmm;g=Nnnnn;,Maint,,M STAT,5555,,,,,,,,,

UPDATE: Evidently the OP has a binary input file with escaped (or otherwise present) delimiters, but did not indicate which of these delimiters are escaped in the sample input.

Lastly, if it really is a binary file, don't forget to use binmode.

UPDATE: Given Corion's decision to remove any potentially personally identifiable information (a decision which I support), the above will need to be changed to reflect the new sample input... done.

During the anonymization I discovered that while coping the OP's sample input I accidentally mangled the first one -- the first `cut` output has been updated to reflect this. While the second was not mangled, it has lost context with the removal of the additional sample lines.

Nevertheless, the problem remains that the OP was using the incorrect column specification.

UPDATE: Changed the for loop from the OP's implementation to actually maintain the quoted values.