Re: "Secret" operators

José Castro <[email protected]>
Newsgroups gmane.comp.lang.perl.fun
Message-ID <[email protected]>
* Ronald J Kimball ([email protected]) wrote:
> You can assign two elements to a one-element list:
> 
> ($foo) = (1, 2);
> 
> You can even assign two elements to an empty list:
> 
> () = (1, 2);
> 
> 
> In each case, any extra elements are simply discarded, but the result of
> the assignment in scalar context is always the number of elements on the
> right-hand side, even if some aren't actually assigned to variables.

Which is why this:

perl -e '$_ = ($foo) = (1, 2) ; print'

prints out 2.

--
Jose Alves de Castro <[email protected]>
      http://jose-castro.org/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.