On Wednesday 05 December 2007 09:53, Perl WANNABE wrote:
> * Dr.Ruud <[EMAIL PROTECTED]> [2007-12-02 14:34]:
> > John W . Krahn schreef:
> > > Eric Krause:
> > >
> > > $ perl -le'
> > > $_ = q[11111xxx11xxxx111111xx11x1xxxx];
> > > print;
> > > s/(1+)/@{[($l=$1)=~y|1|1|]}/g;
> > > print;
> > > '
> > > 11111xxx11xxxx111111xx11x1xxxx
> > > 5xxx2xxxx6xx2x1xxxx
> > >
> > > :-)
> >
> > Aiaiaiai.
> >
> > $ perl -le'
> > $_ = q[11111xxx11xxxx111111xx11x1xxxx];
> > print;
> > 1 while s/(\d)(\d)/@{[0==print, $1+$2]}/;
> > print;
> > '
> > 11111xxx11xxxx111111xx11x1xxxx
> > 11111xxx11xxxx111111xx11x1xxxx
> > 2111xxx11xxxx111111xx11x1xxxx
> > 311xxx11xxxx111111xx11x1xxxx
> > 41xxx11xxxx111111xx11x1xxxx
> > 5xxx11xxxx111111xx11x1xxxx
> > 5xxx 2xxxx111111xx11x1xxxx
> > 5xxx 2xxxx 21111xx11x1xxxx
> > 5xxx 2xxxx 3111xx11x1xxxx
> > 5xxx 2xxxx 411xx11x1xxxx
> > 5xxx 2xxxx 51xx11x1xxxx
> > 5xxx 2xxxx 6xx11x1xxxx
> > 5xxx 2xxxx 6xx 2x1xxxx
>
> As this is a beginner's list I'll dare ask the question.
>
> Can someone please help me understand why this works or better still
> point me to some documentation where I can read more and get my teeth
> into this kind of thing!
>
> I thought I was pretty good at regular expressions but this creation
> of what seems a nameless hash in the replacement side of the regular
> expression is something I've never seen before, both John and Affijn
> do this @{ [ ] } anonymous array of hash which isn't because inside
> the [ ] you have a function ?
perldoc -q "How do I expand function calls in a string"
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/