in reply to split on the pattern of '),('
I don't know why it is not working for you but piece of code below works for me
my @arr = split(/\),\(/, $str);
I have used strict and warnings and here is my entire code. It also works if you didn't use strict or warnings.
#!/tools/bin/perl use strict; use warnings; my $str = '(1,"(text)", 123),(2,"(string)", 234),(...)'; my @arr = split(/\),\(/, $str); for(my $i = 0; $i<= $#arr; $i++){ print $arr[$i],"\n"; } exit; ##### OUTPUT #### (1,"(text)", 123 2,"(string)", 234 ...)
Try running the above code
|
|---|