in reply to Re: Splitting a string on commas except when inside quotes
in thread Splitting a string on commas except when inside quotes

my $line = '11/21/2022,Payment,"Transfer to Smith, account 2",,USD,,123.60,'; print " $line\n"; my ( $fDate, $fType, $fDetails, $fRef, $fCurrency, $fAmount, $fPaidOut, $fFees ) = "$line," =~ /(".*?"|[^,]*),/g; # NOTE
What is that comma and double quotes doing to $line?

Replies are listed 'Best First'.
Re^3: Splitting a string on commas except when inside quotes
by tybalt89 (Monsignor) on Jan 02, 2023 at 20:38 UTC

    The regex looks for a trailing comma for every field. "$line," just adds one for the last field.