Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Conditional Map?

by blakem (Monsignor)
on Oct 07, 2002 at 11:45 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://203294]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-19 02:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found