$x = 0;
sub f { return $x; }
sub g { local $x = 1; }
sub z { g(); local $x = $x + 2; return f(); }
print z()."\n";
can someone explain me why it gives such an output?
since I use dynamic scoping for the variable x in won't this variable go to the top of the stack and be used in the expression $x = $x + 2 = 1 + 2 = 3?
sub f { return $x; }
sub g { local $x = 1; }
sub z { g(); local $x = $x + 2; return f(); }
print z()."\n";
can someone explain me why it gives such an output?
since I use dynamic scoping for the variable x in won't this variable go to the top of the stack and be used in the expression $x = $x + 2 = 1 + 2 = 3?