in reply to Scope Puzzle
As an optimization (I suspect) of an implementation detail, perl translates lexical variables into array accesses, where each lexical pad is an array. That's not quite exactly correct, but it's close enough to explain why you can look up and rebind global symbols -- those that live in the symbol table -- but not lexicals. perl always looks up global symbols (package variables, subroutine names) by name and lexical symbols by lexical pad index.
If you examine the optree with B::Concise or a similar module, you'll notice the difference in gvsv and padsv ops.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Scope Puzzle
by Anonymous Monk on Feb 17, 2006 at 08:12 UTC |