[EMAIL PROTECTED] schreef op 06 december 2001:
> On Thu, 06 December 2001, [EMAIL PROTECTED] 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

Reply via email to