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).
No, the ^ twigil is only necessary in the first occurrence. That was introduced because things like this:
my $block = { my $v = %hash{$^key}; say "The lookup {%hash{$^key}} yields $v"; };
Would complain about the closure inside the string getting no argument, because $^key was interpreted as a formal parameter to the inner-most closure, which in this case was the one inside the string.
Or more general, you couldn't refer to outer lexicals that happened to be self-declaring formal parameters.
So it was decided that after $^foo occurred once, you could refer to it as $foo to, disambiguating it in inner blocks.
In reply to Re^3: Rosetta PGA-TRAM
by moritz
in thread Rosetta PGA-TRAM
by eyepopslikeamosquito
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |