Rick writes: > Ton Hospel wrote: > > > > Also fun is this: > > > > perl -wle '$_="abcde"; pos=1; print $& while /.\G./g' > > ab > > bc > > cd > > de > > > > But I could build nothing useful with that (s/// does not restart) > > Here's a fun one I looked at (but same problem): > > perl -wle '$_="abcde"; --pos, print $& while /../g'
When I first read the rules, I immediately thought 'recursion'. So, one of my first tries, which I classify as 'fun' is: #!perl -l sub f{$_[0]>9?pop=~/./&&&f($&+$'):0+pop} print$_=pop;{--pos,$y.=f($&)while/../g;print$_=$y;$y='';$_>9&&redo} I just couldn't stand the double print though :) Ala