> Bryan R Harris wrote:
>> 
>>>> 2) perl -le '$x = qw/a b c d e/; print $x'
>>>> e
>>>> Or better what is (2) doing?
>>> Read up on the comma operator in perlop (and I know there are no literal
>>> commas in (2) but qw/a b c d e/ behaves exactly the same as ('a', 'b', 'c',
>>> 'd', 'e').)
>>> 
>>> perldoc perlop
>> 
>> 
>> Why would this be considered a binary (?) use?  I read the documentation,
>> but I think I'm missing something, it doesn't make sense.
>> 
>> This is really bizarre and unexpected for me (I'm not the OP, by the way).
>> Can someone help train my intuition as to why these aren't identical?  And
>> why they shouldn't be?
>> 
>> % perl -le '$x = @{[ "a","b","c","d","e" ]}; print $x'
>> 5
>> 
>> % perl -le '$x = ("a","b","c","d","e"); print $x'
>> e
> 
> @{} is an array so it returns the number of elements.  (The anonymous array in
> [] is dereferenced by @{}.)
> 
> "a","b","c","d","e" is a list so each element is evaluated and discarded and
> the last element is assigned to the scalar.


Ah.  What I was missing is that a list is *not* the same as an array.
Interesting, thanks.

For those following this thread (probably nobody), this is demonstrated
exactly in Programming Perl, 24.1.2 (I just found it right now).

- B




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to