On 10/03/2016 06:17 PM, khalil zakaria Zemmoura wrote:
Hi,
I am reading modern Perl and despite the explanation of the author I
couldn't understand:

my $count = () = get_clown_hats()

It's obvious to me that the function get_clown_hat() is evaluated in
list context but what the author said is that
the assignment to the empty list throws away all of the values of the
list, but the assignment takes place in scalar context, which evaluates
to the number of items on the right!

So - imagine if you did the assignment through a temp variable

my @clown_hat = get_clown_hats();

# @clown_hat = [ qw/ pointy silly fuzzy whatever/ ]

my $count = @clown_hat;

# $count == 4


If someone could explain that, it would be great.


the =()= "operator" just does that without creating a temporary variable



Thanks
Regards



--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to