<?xml version="1.0" encoding="windows-1252"?>
<node id="1013589" title="Re: How does 'goto LABEL' search for its label?" created="2013-01-16 10:32:37" updated="2013-01-16 10:32:37">
<type id="11">
note</type>
<author id="961">
Anonymous Monk</author>
<data>
<field name="doctext">
&lt;p&gt; [doc://goto] says (among other things) &lt;blockquote&gt;Use of "goto-LABEL" or "goto-EXPR" to jump into a construct is
deprecated and will issue a warning. Even then, &lt;b&gt;it may not be
used to go into any construct that requires initialization, such
as a &lt;b&gt; subroutine or a "foreach" loop.&lt;/b&gt; &lt;/b&gt; It also can't be used to go
into a construct that is optimized away.&lt;/blockquote&gt;
&lt;p&gt; So LABELs are like lexicals, except with only file-scope or subroutine-scope ( [id://213855|Lexical scoping like a fox] )
&lt;p&gt; lexical(my) variables from one loop/block is not visible in another, but labels are , because they currently have file scope (like my $foo at the top of a file outside of any bare blocks)
&lt;p&gt; currently &lt;tt&gt; { L: say 1; }&lt;/tt&gt; is like &lt;tt&gt; my $L; { $L=1; say $L; } &lt;/tt&gt;
&lt;p&gt; But this will change, once &lt;c&gt; Use of "goto" to jump into a construct is deprecated  &lt;/c&gt; is disallowed, labels will be lexically scoped like my $vars
&lt;p&gt; someday &lt;tt&gt; { L: say 1; }&lt;/tt&gt; is like &lt;tt&gt;  { my $L=1; say $L; } &lt;/tt&gt;
</field>
<field name="root_node">
1013574</field>
<field name="parent_node">
1013574</field>
<field name="reputation">
12</field>
</data>
</node>
