in reply to rearranging matched parts of a string while using /g and without using split
(updated, original code only handled tokens that were 1 char long)$_='A # B # 1 # 2'; my @tokens=/\w+/g; print join ' # ', @tokens[map($_*2,0..$#tokens/2),map(1+$_*2,0..$#tokens/2)];
|
|---|