Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^4: Possible useless use of map

by JavaFan (Canon)
on Mar 18, 2010 at 15:04 UTC ( [id://829418]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Possible useless use of map
in thread Possible useless use of map

Just like about any other operator in Perl, map imposes a certain context on its operands, regardless of the context it itself is in. In:
map {$hash->{foo}} 1;
there are actually two lists, both containing a single element: the first list consists of $hash->{foo}, the second of 1.

Think of it this way, if map would not provide list context to its inner block, the following wouldn't do what it does now:

%h = map {$_ => 1} qw[foo bar baz];

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-03-28 14:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found