>>>>> "David" == David Eason <[EMAIL PROTECTED]> writes:

David> I am not as knowledgeable about such things as you guys, but..
David> Isn't an anonymous array the same thing as an array literal?

No.

:-)

Well, for one thing, there's no such thing as an array literal.
So that's like saying "aren't horses and unicorns really the same thing?".

There is a *list literal*.  That's a bunch of comma-separated values
in a list context:

        @a = (1, 2, "buckle my shoe")
              ======================

An anonymous array is merely an array that does not have a direct
symbol-table or lexical-table name, but is always accessed by
dereferencing some array reference.  One way to create such an array
reference is to enclose a list literal in square brackets:

    my $plan_a = [1, 2, "buckle my shoe"]

But another equally valid way is to take a reference to a named
array, but let the name go out of scope:

    my $plan_b;
    {
      my @name = (1, 2, "buckle my shoe");
      $plan_b = \@name;
    }

Both $plan_a and $plan_b now refer to anonymous arrays.

(In the past week, I just finished writing this stuff up for my next
book... see the bookshelves in six months or so.)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to