#!perl -ln s~.~$,=$&;@a=();/^.*(??{push@a,$&.$,.$'})/for@.?@.:'';@.=@a~ge;print for@.