develooper Front page | perl.perl5.porters | Postings from November 2010

Re: [perl #79908] my $x; sub(){$x} makes a constant even if $xchanges

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
November 29, 2010 01:22
Subject:
Re: [perl #79908] my $x; sub(){$x} makes a constant even if $xchanges
Message ID:
20101129092227.GD2685@iabyn.com
On Sun, Nov 28, 2010 at 05:16:28PM -0800, Father Chrysostomos wrote:
> I know this is what constant.pm used to use, but it causes a bug:

What do you think is the bug? It seems to be behaving the way I expect.

> $ perl -MO=Deparse -e' BEGIN{my $x = 5; *foo = sub(){$x}; $x=6} print foo'
> sub BEGIN {
>     my $x = 5;
>     *foo = sub () {
>         $x;
>     }
>     ;
>     $x = 6;
> }
> print 5;

-- 
Lady Nancy Astor: If you were my husband, I would flavour your coffee
with poison.
Churchill: Madam - if I were your husband, I would drink it.

Thread Previous | 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