>>>>> "Brett" == Brett W McCoy <[EMAIL PROTECTED]> writes:

Brett> On Thu, 21 Jun 2001, Timothy Kimball wrote:
>> Randal L. Schwartz wrote:
>> : ...
>> : Second might mean something like:
>> :
>> : $foo_length = SOME_LIST # although this can't happen
>> :               ========= list
>> :             =           assigned to
>> : ===========             scalar
>> :
>> : See the difference?  And the latter can't happen.
>> 
>> Sure it can. Well, the list itself doesn't get assigned to the scalar,
>> but an assignment does get made: The last element of SOME_LIST to
>> $foo_length. So
>> 
>> my $number_of_pets = ('dog','cat','iguana');
>> 
>> sets $number_of_pets to 'iguana'.

Brett> It's still scalar to scalar assignment.  The list isn't getting assigned
Brett> to anything -- there's no list context so there is no list assignment.

And there's actually no list being formed.  It's a scalar
"comma-expression" on the right, semantic-wise.  'A, B' in a scalar
context means 'eval A, throw away, eval B, returning B', recursively
for a long list.

Yeah, I know we use "list" in the docs both for "comma-separated
syntax thingy" and "value with multiple scalars", but they really are
different, and it's important to distinguish the two.

At no time does Perl create a list of values for:

        $a = ('fred', 'barney', 'dino');

So we still don't have "$a = LIST".  We have "$a = _scalar context_"
and when _scalar context_ is applied to a comma-ish thing, it's the
comma operator (eval, discard, eval, discard, eval, keep).

-- 
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!

Reply via email to