in reply to Interpolating a string into list context.
use strict; use warnings; my $str = q{"one","two", "not three" , ' four',"five " }; my @arr = $str =~ m {(?x) (?<=['"]) ([^,'"]+) (?=['"]) }g; print qq{-->$_<--\n} for @arr;
Here's the output.
-->one<-- -->two<-- -->not three<-- --> four<-- -->five <--
This method is going to fall down pretty quickly as your data gets more complex and I agree with others who have suggested some sort of CSV module to tackle the problem.
Cheers,
JohnGG
|
|---|