Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^3: Idiom to return 0 or random number of array elements

by tobyink (Abbot)
on Dec 07, 2012 at 12:29 UTC ( #1007728=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Idiom to return 0 or random number of array elements
in thread Idiom to return 0 or random number of array elements

With $hash{...} a scalar context is imposed on the key. With a slice like @hash{...} list context is imposed on the key.

use 5.010; use strict; sub WA { return wantarray } my %hash = ('' => 'Hello ', '1' => 'World'); say $hash{ WA() }, @hash{ WA() };
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'


Comment on Re^3: Idiom to return 0 or random number of array elements
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1007728]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (14)
As of 2015-07-03 12:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (53 votes), past polls