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

Re: The Santa Claus Golf Apocalypse

Thread Previous | Thread Next
Bernie Cosell
December 5, 2001 05:05
Re: The Santa Claus Golf Apocalypse
Message ID:
On 5 Dec 2001, at 12:40, Piers Cawley wrote:

> "Bernie Cosell" <> writes:
> > On 5 Dec 2001, at 18:04, wrote:
> >
> >> Piers Cawley wrote:
> >> > I think the particular 'creative in the extreme' entry that Andrew was
> >> > referring to was my that printed 10 lines then crashed using:
> >> >
> >> >     #!perl -p
> >> >     11..&

> > Me, too. Is that actually exploiting a bug in perl? [which is legit,
> > of course -- I just seeking some clarification/understanding here].
> > It seems that "&<ENDOFFILE>" is interpreted as a subroutine call to
> > a subtroutine with no name.
> It depends on how the -p works. And it's (sort of) documented.

I realize that, but still it seems odd that the construct:
actually calls a null-named subroutine rather than giving you a syntax error.  
For example, if I write this perl program:
no -p trickery or the like, I'd have *assumed* that that would get me a syntax 
error.  So I was just musing that it looks like at the very least an un- [semi-
?  hidden-?] kind-of-anomaly that Perl doesn't give a syntax error on that. 
[sort of like when I first learned of the hack in the -w stuff for the string 
"0 but true", which, AFAIK, is also undocumented]

Meta-question: since Perl is content to try to *call* '&main::;' is there some 
trickery to *DEFINE* such a subroutine?  For example, trying:
   main:: { die; }
gets you what I would have expected in the '..&' case: a syntax error for a 
missing subroutine name.

Bernie Cosell                     Fantasy Farm Fibers     Pearisburg, VA
    -->  Too many people, too few sheep  <--          

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