in reply to rearranging matched parts of a string while using /g and without using split

Is two lines OK?
$_='A # B # 1 # 2'; my @tokens=/\w+/g; print join ' # ', @tokens[map($_*2,0..$#tokens/2),map(1+$_*2,0..$#tokens/2)];
(updated, original code only handled tokens that were 1 char long)
  • Comment on Re: rearranging matched parts of a string while using /g and without using split
  • Download Code