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

Re: Conditional Map?

by blakem (Monsignor)
on Oct 07, 2002 at 11:45 UTC ( #203294=note: print w/replies, xml ) Need Help??


in reply to Conditional Map?

To "zero out" an element using map, simply return an empty list for that value...
my @evens = map { $_%2 ? () : $_ } 1..10;
So, you'd need to do something like this:
my %hash = map { /^f/ ? () : (getkey($_) => $_) } @array;

-Blake

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2019-08-24 00:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?