in reply to Split at multiple delimiters and get the delimiter
If the PATTERN contains parentheses, additional list elements are created from each matching substring in the delimiter.You can therefore get your desired result with split /(:|%|;)/, where your result list will alternate data and delimiter. If you really want to split it into two arrays, you could do something like:
my @values; my @delims; for (split /(:|%|;)/) { if (@values == @delims) { push @values, $_; } else { push @delims, $_; } }
|
|---|