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.
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>