$line = 'f1 , f2, "hello , world" , "nice , try" ';
$line =~s|"([^"]*?)"|{$_=$^N;tr','.';$_}|gse;
print scalar (split /\s*,\s*/,$line,-1);
So I use this regex to change the invalid commas to dots, but I am looking
something more generic. Any Ideas ?
There are modules available from CPAN to handle this sort of input.
See, for example, Text::CSV.
--
Jim Gibson
Yes, as the applicable FAQ entry says.
perldoc -q delimited
> See, for example, Text::CSV.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl