in reply to do, local and a qualified identifier?
local scopes variables temporally, for the duration of execution of a piece of code.
In the code you show, it executes on loading as part of the file’s main code. The function does not execute in the course of that invocation. After execution falls off the end of the file, the localisation is reverted.
When the init function is called, the local’s effect is long forgotten, so the caller’s view of $Foo::bar is affected by the assingment.
Strictly per your example, there is no point in localising the variable like that. I don’t know if it’s not sensible in the real code, though.
Makeshifts last the longest.
|
|---|