develooper Front page | perl.perl5.porters | Postings from October 2003

Re: [perl #24250] "return" required in some anonymous closures

Nick Ing-Simmons
October 20, 2003 05:34
Re: [perl #24250] "return" required in some anonymous closures
Message ID:
Elizabeth Mattijsen <> writes:
>(I should stop answering my own posts  ;-)
>At 11:55 +0200 10/20/03, Elizabeth Mattijsen wrote:
>>Hmmm... both of the following return correct results also:
>The problem can be simplified to the following code:
>my $foo = 'foo';
>my $get = sub () {$foo};
>my $set = sub ($) {$foo = $_[0]};
>print "foo = $foo = ".$get->()."\n";
>foo = bar = foo
>so this looks like an optimizer problem to me: the $get sub is 
>referring to something else than the package lexical $foo.

What is a 'package lexical' ?
  - things are either in package or lexical never both... Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About