<?xml version="1.0" encoding="windows-1252"?>
<node id="1014476" title="Re: foreach-loop-local var in sub" created="2013-01-21 11:02:38" updated="2013-01-21 11:02:38">
<type id="11">
note</type>
<author id="832495">
choroba</author>
<data>
<field name="doctext">
Defining a named sub in a loop is not doing what you think. The sub is defined just once, using the &lt;c&gt;$i&lt;/c&gt; of the first iteration. On the next iteration, a new &lt;c&gt;$i&lt;/c&gt; is created by [doc://my], but the sub is not redefined and still references the previous &lt;c&gt;$i&lt;/c&gt;. It is better to use parameters to pass values to subroutines.&lt;p&gt;If you remove [doc://my] (and, under [doc://strict], replace it with [doc://our]), the intended behaviour will occur, using a global variable.
&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-832495"&gt;

&amp;#1604;&amp;#1405;&amp;#4285;† &amp;#6514;&amp;#6482;&amp;#9898;&amp;#10186;&amp;#4281;&amp;#5651;&amp;#5511; &amp;#5045;&amp;#5651;&amp;#5511;&amp;#9137; &amp;#4281;&amp;#6514;&amp;#119243;&amp;#409;&amp;#5651;&amp;#5511;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1014473</field>
<field name="parent_node">
1014473</field>
</data>
</node>
