develooper Front page | perl.fwp | Postings from December 2001

Re: Santa Hole 1 (head.pl) Post Mortem

Thread Previous
From:
Eugene van der Pijll
Date:
December 6, 2001 16:44
Subject:
Re: Santa Hole 1 (head.pl) Post Mortem
Message ID:
20011207014437.B3451@ruunat.phys.uu.nl
aaron@marasco.com schreef op 06 december 2001:
> On Thu, 06 December 2001, Andrew.Savige@ir.com wrote:
> > --- Aaron D Marasco ------------------ 12
> > #!/usr/bin/perl -p
> > 11..exit;
> 
> [ Duh... semicolon... just to say publicly what I said on
> submission... he encouraged newbies... :) ]

I forget to remove the semicolons sometimes too... You also missed a
space in rev.pl, and didn't use the famous }{ trick in wc.pl.
With a bit more experience, you would have equalled the best score at
all of those holes, which is not bad at all for a newbie.

These are things which will probably be in the first chapter of the Perl
Golf handbook that Japhy proposed. I would be glad to help with that,
by the way.

> > --- Yanick --------------------------- 13
> > #!/usr/bin/perl -p
> > $_ x=$.<11
> 
> Can this one be explained please? (And can we keep explanations in the
> per-hole threads?)

$_ = $_ x ($.<11);

$_ is repeated ($.<11) times. So for the first ten lines, $.<11
evaluates to 1, and $_ stays the same. For the other lines, $.<11 is
false, which evaluates to 0 in a numeric context, and $_ is repeated
zero times, so $_=''.

Eugene

Thread Previous


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