go ahead... be a heretic | |
PerlMonks |
Re: x 5 Tribute to TMTOWTDI (A question of scope)by demerphq (Chancellor) |
on Oct 26, 2001 at 18:24 UTC ( [id://121632]=note: print w/replies, xml ) | Need Help?? |
Regardless of any contortions Benchmark goes through to execute code in the calling package, lexical variables are not in any package. It is impossible for code to access lexical variables that are not in scope. No arguments here. My only problem with your post was the line I quoted. I've just reread your original post and you have to admit its a little ambiguous. Yes the code is executed inside of the _file_ Benchmark, but not in the package Benchmark. And this leads to an interesting point (about which Ill have to trawl the docs for at a later time) the two are different. Consider the below code Now if you do perl TestB.pm you will see But if you stick the entire code snippet into TestB.pm then you will see Even though you might expect that the lexical variable $var would be out of scope.
(Incidentally I have a development Lib directory that I use for this type of stuff and have my enviornment configured to always include it.)
Yves / DeMerphq -- Have you registered your Name Space?
In Section
Meditations
|
|