develooper Front page | perl.perl5.porters | Postings from September 2001

Re: [ID 20010930.005] interpolated BEGIN oddities

Thread Previous
From:
Rafael Garcia-Suarez
Date:
September 30, 2001 12:42
Subject:
Re: [ID 20010930.005] interpolated BEGIN oddities
Message ID:
20010930214607.A691@rafael
On 2001.09.30 14:56 Hugo van der Sanden wrote:
> 
> Under perls at least from 5.005_03 to blead@12163, I get this oddity:
> 
>   crypt% ./perl  -wle 'print qq;@{[ BEGIN { print "BEGIN" } ]};'
>   BEGIN
>   Can't call method "BEGIN" without a package or object reference at -e line 1.
>   crypt% 

I don't really see your point. What is odd here is the syntax and how the parser
tries to intuit it. In this context, "BEGIN { print "BEGIN" }" looks like an indirect
object method call. See : (with bleadperl)

$ perl -wle 'foo { print "foo" };'
foo
Can't call method "foo" without a package or object reference at -e line 1.

$ perl -wle 'foo { print "foo"; bless {} };'
foo
Can't locate object method "foo" via package "main" at -e line 1.

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