Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Scalar context of slice

by JavaFan (Canon)
on Oct 04, 2008 at 01:14 UTC ( #715302=note: print w/replies, xml ) Need Help??

in reply to Scalar context of slice

The canonical way of getting the number of elements of the list a function returns in list context is not by using 'map' (although that will work), but by assigning the result to an empty list, and assigning that to a scalar:
my $count = () = expression_in_list_context;
And if you remove some spaces, you're left with one of Perls secret operators:
my $count =()= expression; # Goatse operator.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://715302]
[marto]: good morning all
[Corion]: Hi marto!
[Corion]: Oooh - finally, I can say no lazy; :)
[Corion]: But it's another The::Net incarnation, too sad ;)
[Corion]: WTF? There is a dev release of Danga::Socket?! I thought that module died a long time ago?! According to its changes, the last release was in 2008 ;)
[Corion]: (and Brad Fitzpatrick long since moved on to Go ;) )

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (9)
As of 2018-07-17 08:10 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (359 votes). Check out past polls.