works as desired. (I'm sure that “dynamic scoping” isn't the right term for that, but I didn't know a better.) The real difficulty (for me, anyway) is making a change in an inner scope to a lexical variable in an outer scope in such a way that the change will ‘revert’ outside that scope.my $x = 1; my $f = sub { $x }; { $x = 2; print $f->(), "\n"; # => 2 }
In reply to Re^2: Local for lexicals
by JadeNB
in thread Local for lexicals
by JadeNB
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |