On Wed, Aug 01, 2001 at 12:13:46PM +1000, [EMAIL PROTECTED] wrote:
> With my last golf game, this worked fine:
>  perl -anF// -e'@F{%F=@F}=0;121-@F*keys%F||print' words
> Then I created a file, f.pl, consisting of:
>  #!/usr/bin/perl -anF//
>  @F{%F=@F}=0;121-@F*keys%F||print
> and typed:
>  ./f.pl words
> and this worked fine too. However, when I now tried:
>  perl f.pl words
> this failed with a syntax error!
> This is more of a pest under Windows than Unix.
> 
> I then tried:
>  perl -lpe'$.==1 and $_.="\0"' f.pl >g.pl
> to null-terminate the #!/usr/bin/perl line and now:
>  perl g.pl words
> worked just fine!
> 
> I think the reason for all this is that in:
>  perl -anF// ...
> the -F string (in C's argv[]) is null-terminated, while in the:
>  #!/usr/bin/perl -anF//
> line it is not.
> 
> Is this behaviour considered a bug or a feature or a botch?

Personally, I think it's a bug, but perhaps it was meant to be that way.


The same thing happens with -s, which turns on basic switch processing:

s.pl:

#!perl -s

print $foo, "\n";


% s.pl -foo
1
% perl s.pl -foo

% perl -s s.pl -foo
1


Apparently, some switches just get ignored on the shebang line when the
perl intrepeter is specified on the command line.

It's sort of like -T, except that gives you a fatal error instead of
failing silently.

Ronald

Reply via email to