|XP is just a number|
How does 'goto LABEL' search for its label?by moritz (Cardinal)
|on Jan 16, 2013 at 13:50 UTC||Need Help??|
moritz has asked for the
wisdom of the Perl Monks concerning the following question:
At $dayjob I'm working on a project where the home-grown error reporting module occasionally warns Use of "goto" to jump into a construct is deprecated
So now I'm trying to find out how exactly goto LABEL works, in order to assess whether the whole error reporting module needs to be rewritten. And I found no documentation.
The closest I found was "goto only searches the immediate call stack for labels", but this alone doesn't explain how "jump into a construct" can happen at all -- if it only searched the caller's scope and the caller's caller's scope etc. for the label, it would never find label from inside a construct that's not in dyanmic call chain.
Some curious experiments:
So apparently, the construct containing the label has to have been executed once.
Whereas this one dies:
I have trouble finding a clear mental model that can help me to explain all of this behavior. Who can help?