Andrew Savige wrote :
> I think I should highlight what I think is a Perl bug that affects
> golf games.
> 
> You can find all 12-letter words with no repeating character with:
> 
> perl -anF// -e'my%F;@F{@F}=F;169-@F*keys%F||print' /usr/dict/words
> 
> (That solution would definitely not win a fwp golf game :)
> 
> You may be surprised to learn, however, that this fails:
> 
> fred.pl:
> #!/usr/bin/perl -anF//
> my%F;@F{@F}=F;169-@F*keys%F||print
> 
> perl fred.pl /usr/dict/words          (oops, syntax error)
> 
> Interestingly, you can make fred.pl work by manually
> null-terminating the first line. For example:
> 
> adjust.pl:
> #!/usr/bin/perl -lp
> $.==1 and $_.="\0"
> 
> perl adjust.pl fred.pl >fred2.pl
> perl fred2.pl /usr/dict/words         (this works!)

The behaviour of -F on the shebang line will be, uh, fixed, in 5.8.0.
Currently (as of 5.6.1) the argument to -F should be terminated by a \0
(as if it were passed into argv). Now, on the shebang line, the parsing
of this argument ends when a whitespace is encountered.

This means that
    #!/usr/bin/perl -F/xyz/ -an
will be valid, but
    #!/usr/bin/perl "-F/ /" -an
won't.

> I am mentioning this because it may affect the scoring rule
> if a golf solution uses the -F option. I suggest you allow
> the null-terminate hack and subtract one from the golf score
> (because you do not require the terminating null when you run
> directly from the command line via -e).

<scrooge>A byte, even a null one, is a byte.</scrooge>

> Thankfully, this did not affect Santa's game because -F was
> quite useless there.
> 
> There are some other options that work directly from the command
> line but do not work via shebang. However, -F is the only one
> that I can think of that is vital to golfers.

Side note. A golfer may turn perl bugs (and other internal oddities) to
its own advantage. That's why defining the set of perl versions allowed
for submissions is important.

Reply via email to