I have a CSV file in the format shown below, and I’m using the Perl split command as shown, based on comma as delimiter. The problem is I have a quoted string "HTTP Large, GMS, ZMS: Large Files" with embedded commas and it fails. The array values will have only less elements. How can I modify the split command.
my @values = split('\,', $line);
CSV File
10852,800 Mob to Int'l,235341739,573047,84475.40,0.0003,Inbound,Ber unit
10880,"HTTP Large, GMS, ZMS: Large Files",52852810,128,13712.68,0.0002,,Rer unit
13506,Presence National,2716766818,2447643,309116.40,0.0001,Presence,per Cnit
Issues like embedded commas are precisely why modules such as
Text::CSVwere created. If, but only if, the data does not have embedded commas, then you can make regular expressions work. When the data has embedded commas, it is time to move to a tool designed to handle CSV with embedded commas, and that would beText::CSVin Perl (and its relativesText::CSV_PPandText::CSV_XS).