in reply to Re: Local for lexicals
in thread Local for lexicals
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 }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Local for lexicals
by JavaFan (Canon) on Aug 10, 2009 at 16:08 UTC | |
by JadeNB (Chaplain) on Aug 10, 2009 at 16:13 UTC | |
by JavaFan (Canon) on Aug 10, 2009 at 16:22 UTC | |
by doom (Deacon) on Aug 10, 2009 at 21:26 UTC | |
by LanX (Saint) on Aug 10, 2009 at 22:12 UTC | |
by JadeNB (Chaplain) on Aug 10, 2009 at 16:27 UTC |