in reply to Re^4: Variable name
in thread Variable name
since the only way to find variables by name is in the symbol table, we can't possibly get a lexical this way.
In theory, the mechanism used by PadWalker could be used to lookup lexicals by name... it just isn't being done with symbolic references.
#!/usr/bin/perl use strict; use warnings; use PadWalker; my $foo="foo"; my $bar="f"; my $p = PadWalker::peek_my(0); print ${$p->{'$'.$bar.'oo'}}, "\n"; # "foo"
|
|---|