develooper Front page | perl.fwp | Postings from March 2002

RE: TPR1 post-mortem

Thread Previous | Thread Next
From:
Ala Qumsieh
Date:
March 8, 2002 14:10
Subject:
RE: TPR1 post-mortem
Message ID:
8812A03F65CDD511AE98006008F5E8712825E5@hermes.hyperchip.com

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

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About