Jonathan Scott Duff wrote:
> 
> On Wed, Apr 03, 2002 at 12:41:13PM -0500, John Siracusa wrote:
> > Reading EX4 and seeing those "place-holder" variables made me wonder what
> > happens when someone (probably Damian ;) wants to use more than 26 of them.
> > Do the place-holder names scale up as if they're being automagically
> > incremented? (e.g. ..., y, z, aa, ab, ...)
> 
> Hmm.  I was just reading on use.perl.org and Damian said this:
> 
>         Magic $^ variables are only magic in that they allow a
>         subroutine to be declared without an explicit sub keyword or an
>         explicit parameter list. Instead, their parameter list is
>         constructed implicitly: it's just the alphabetically sorted list
>         of the names of all the magic $^ variables within the block.
> 
> So I may be wrong about { $^foo * $^bar } being equivalent to
> {$^a * $^b }.
> 
> Waiting for the Damian or the Larry to chime in ...

<bing!>

The closure:

        { $^foo * $^bar }

is equivalent to:

        sub ($^bar, $^foo) { $^foo * $^bar }

So you're right about being wrong about the equivalence.

The $^ variables are sorted ASCIIbetically in the implied parameter list.
Which is why:

        sort { $^b <=> $^a } @list

DWIMs.

Damian

Reply via email to