http://www.perlmonks.org?node_id=890826


in reply to Split at multiple delimiters and get the delimiter

Just add parens:

split /(:|%|;)/
and the delimiters will be captured ... but why put them in another array? Surely you won't be able to line them back up again ...

Update: regardless of why, you could do something like so:

/\W/ ? push @a,$_ : push @b,$_ for split /(:|%|;)/
Where @a would contain the delimiters and @b contains the data ...

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)