<?xml version="1.0" encoding="windows-1252"?>
<node id="772565" title="Re^3: Rosetta PGA-TRAM" created="2009-06-17 18:42:16" updated="2009-06-17 18:42:16">
<type id="11">
note</type>
<author id="616540">
moritz</author>
<data>
<field name="doctext">
&lt;blockquote&gt;Why does the block use $^a in one place (the automatic parameter) and $a in another place? Shouldn't that be a different (undeclared) variable? (Likewise for b).&lt;/blockquote&gt;

&lt;p&gt;No, the &lt;c&gt;^&lt;/c&gt; twigil is only necessary in the first occurrence. That was introduced because things like this:

&lt;code&gt;
my $block = {
      my $v = %hash{$^key};
      say "The lookup {%hash{$^key}} yields $v";
};
&lt;/code&gt;

&lt;p&gt;Would complain about the closure inside the string getting no argument, because &lt;c&gt;$^key&lt;/c&gt; was interpreted as a formal parameter to the inner-most closure, which in this case was the one inside the string.

&lt;p&gt;Or more general, you couldn't refer to outer lexicals that happened to be self-declaring formal parameters.

&lt;p&gt;So it was decided that after &lt;c&gt;$^foo&lt;/c&gt; occurred once, you could refer to it as &lt;c&gt;$foo&lt;/c&gt; to, disambiguating it in inner blocks.</field>
<field name="root_node">
771219</field>
<field name="parent_node">
772560</field>
</data>
</node>
