develooper Front page | perl.fwp | Postings from February 2005

Re: "Secret" operators

Thread Previous | Thread Next
From:
José Castro
Date:
February 1, 2005 09:40
Subject:
Re: "Secret" operators
Message ID:
20050201174038.GB24297@natura.di.uminho.pt
* Ronald J Kimball (rjk-perl-fwp@tamias.net) 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 <cog@cpan.org>
      http://jose-castro.org/

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About