in reply to Scope surprise
To put it more succinctly,
There are three variables in scope with the same name (package var $foo aka $main::foo, the first lexical var $foo and the second lexical var $foo) so Perl needs to choose one to use. Perl always chooses the last one declared, falling back on the package var.
By the way, you would have gotten a warning.
Update: Fixed type in var name.
|
|---|