in reply to Re^2: Eval doesn't see lexicals
in thread Eval doesn't see lexicals
The quibble is that I strongly suspect some confusion about how lexical scope works. Coping with Scoping may clarify that. In short, a package declaration affects global variables, not lexical. So lexical variables in scope remain in scope across the package declaration. Like this:
Hence the braces as done in the examples for Class::Std serve the purpose of making lexical scope match package scope. Which is important when you're going to want separate lexical variables with the same name.my $foo = "bar"; package Baz; print "$foo\n"; # prints bar
|
|---|