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

Reply via email to