Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: Rosetta PGA-TRAM

by moritz (Cardinal)
on Jun 17, 2009 at 22:42 UTC ( [id://772565]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Rosetta PGA-TRAM
in thread Rosetta PGA-TRAM

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.

Replies are listed 'Best First'.
Re^4: Rosetta PGA-TRAM
by John M. Dlugosz (Monsignor) on Jun 17, 2009 at 22:56 UTC
    I see. I must have overlooked that when I read through the diffs with the last version I studied carefully. It's so easy to overlook changed or especially removed things!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://772565]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2024-04-26 06:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found