On Thursday 06 September 2001 06:16 am, Dave Mitchell wrote:
> One further worry of mine concerns the action of %MY:: on unintroduced
> variables (especially the action of delete).
>
> my $x = 100;
> {
>     my $x = (%MY::{'$x'} = \200, $x+1);
>     print "inner=$x, ";
> }
> print "outer=$x";
>
> I'm guessing this prints inner=201, outer=200

Perhaps I missed something, but %MY:: refers to my lexical scope, and not my 
parents, correct?

Why isn't this inner=201, outer=100?

>
> As for
>
> my $x = 50;
> {
>     my $x = 100;
>     {
>       my $x = (delete %MY::{'$x'}, $x+1);
>       print "inner=$x, ";
>     }
>     print "middle=$x, ";
> }
> print "outer=$x";
>
> If delete 'reexposes' an outer version of that variable, then I'd
> speculate the output would be
>
> inner=51, middle=50, outer=50

Again, I though that %MY:: referred to my current scope, in which case the 
delete doesn't do anything.  That would make it 101, 100, 50.

Is my understanding incorrect?

-- 
Bryan C. Warnock
[EMAIL PROTECTED]

Reply via email to