develooper Front page | perl.perl6.language | Postings from May 2005

BEGIN and lexical variables inside subroutines

Thread Next
From:
Benjamin Smith
Date:
May 12, 2005 13:07
Subject:
BEGIN and lexical variables inside subroutines
Message ID:
20050512200648.GA20119@vtrl22.vtrl.co.uk
  sub foo { my $x; BEGIN { $x = 3 }; say $x }
  foo; foo; foo;

Currently in perl5 and pugs this prints "3\n\n\n".

Should BEGIN blocks be able to modify values in lexical variables that
don't really exist yet? (People can use state after all to get a
variable which does exist early enough for them to modify.)


Is there some kind of "prototype pad" (and lexicals) available inside
the BEGIN block, rather than a full runtime pad?

-- 
Benjamin Smith <bsmith@vtrl.co.uk, benjaminsmith86@yahoo.co.uk>

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About