In case the inner scope isn't just a plain block, but a subroutine, you can use PadWalker to get at the outer scope(s):
use PadWalker qw(peek_my); my $a=10; sub { my $a=11; my $my = peek_my(1); # one level up print ${$my->{'$a'}}; # 10 print $a; # 11 }->();
This isn't meant for everyday consumption, though... — better use unambiguous variable names.
In reply to Re^3: How to access outside variable
by Anonyrnous Monk
in thread How to access outside variable
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |