in reply to Re^2: Accessing lexicals in other scopes dynamically by name
in thread Accessing lexicals in other scopes dynamically by name
which we've already established should work. Call the sub from outside the scope in which $x resides and you'll see it fail.my $x="global"; my $test=sub { my $x="pre"; alert($x); # pre my ($name,$val)=@_; eval('$'.$name."='".$val."'"); alert($x); # post }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Accessing lexicals in other scopes dynamically by name
by LanX (Saint) on Jul 30, 2010 at 17:22 UTC | |
by ikegami (Patriarch) on Jul 30, 2010 at 18:09 UTC |