I am trying to do a split on a string with comma delimiter
my $string=\'ab,12,20100401,xyz(A,B)\';
my @array=split(\',\',$string);
If I do
use Text::Balanced qw(extract_bracketed);
my $string = "ab,12,20100401,xyz(A,B(a,d))";
my @params = ();
while ($string) {
if ($string =~ /^([^(]*?),/) {
push @params, $1;
$string =~ s/^\Q$1\E\s*,?\s*//;
} else {
my ($ext, $pre);
($ext, $string, $pre) = extract_bracketed($string,'()','[^()]+');
push @params, "$pre$ext";
$string =~ s/^\s*,\s*//;
}
}
This one supports: