develooper Front page | | Postings from August 2002

Re: Reflections

Thread Previous | Thread Next
Juho Snellman
August 8, 2002 01:11
Re: Reflections
Message ID:
On Thu, Aug 08, 2002 at 08:31:44AM +0100, Stephen Turner wrote:
> So, the empty regexp lets $` escape. How did you discover
> that? Was it a brilliant insight, did you already know it, or was it (more
> likely, in my experience) a fluke born out of desparation? :-)

*cough* I didn't know that the 'for' modifier created a lexical block.
Until Ton announced my "innovation", I thought that it acted just like
the 'while' modifier. :-)

One of my last attempts before going sailing for the weekend was this:

#!perl -l
1=~/$/;($`%1e9*++$n)=~/0*$/ while $ARGV[0]--;print$`%10

After coming back I got to 49 from 50 with my regular approach, and
then stalled. I dug the $` approach back from the archives, dusted it
off a little, and it was almost respectable: 

#!perl -l

Optimize for the empty regexp:

#!perl -l

While -> for: 

#!perl -l
1=~/0*$/;($`%9e9*$_)=~//for 1..pop;print$`%10

And the rest practically writes itself.

> And of course, congratulations to Ton and the other referees for a
> well-designed and well-run competition. Interesting holes, solutions always
> judged promptly, exciting races until the end, and by far the best test
> script we've ever seen!


Juho Snellman
"C:stä on kehitetty Massachusettsin teknillisessä korkeakoulussa kieli
 nimeltä BCPL."  

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About