Bryan thought:
> > my $x = 1;
> > my $y = \$x;
> > my $z = 2;
> > %MY::{'$x'} = \$z;
> > $z = 3;
> > print "$x, $$y, $z\n"
>
> My $x container contains 1. ($x = 1)
> My $y container contains a ref to the $x container. ($x = 1, $y = \$x)
> My $z container contain 2. ($x = 1, $y = \$x, $z = 2)
> My $x container now contains a ref to the $z container.
> ($x = \$z, $y = \$x, $z = 2)
Bzzzt! The line:
%MY::{'$x'} = \$z;
assigns a reference to $z to the *symbol table entry* for $x, not to $x itself.
"3, 1, 3" is the correct answer.
Damian
- Re: What's up with %MY? Ken Fox
- Re: What's up with %MY? Dan Sugalski
- RE: What's up with %MY? Garrett Goebel
- Re: What's up with %MY? Ken Fox
- Re: What's up with %MY? Dan Sugalski
- Re: What's up with %MY? Ken Fox
- Re: What's up with %MY? Bryan C . Warnock
- RE: What's up with %MY? Garrett Goebel
- Re: What's up with %MY? Bryan C . Warnock
- Re: What's up with %MY? Bryan C . Warnock
- Re: What's up with %MY? Damian Conway
- Re: What's up with %MY? Bryan C . Warnock
- Re: What's up with %MY? Ken Fox
- Re: What's up with %MY? Bryan C . Warnock
- Re: What's up with %MY? Dan Sugalski
- Re: What's up with %MY? Ken Fox
- Re: What's up with %MY? Bryan C . Warnock
- Re: What's up with %MY? Dave Mitchell
- Re: What's up with %MY? David L. Nicol
- Re: What's up with %MY? Dan Sugalski
