Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: map2 {} grep2 {} ...

by betterworld (Curate)
on Jul 14, 2011 at 17:30 UTC ( #914401=note: print w/replies, xml ) Need Help??

in reply to map2 {} grep2 {} ...

The solutions offered so far are very sophisticated, but I think the most stupid way is also the most readable:

my %h_prefixed; my %h_numbers; while(my ($key, $val) = each %h) { $h_numbers{$key} = $val if looks_like_a_number($val); $h_prefixed{$key} = "p$val"; }

And it's (probably) not even slower or anything.

For a (maybe a bit) less readable solution, I'd like to offer the following:

my %h_prefixed; @h_prefixed{keys %h} = map "p$_", values %h;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://914401]
[Your Mother]: Moon was mind bending and lovely and what's his nose Sam is *always* fun.
[LanX]: the new BS Galactica series is my all time SoapFiction favourite ...
[Your Mother]: I even liked "The Arrival" and I generally hate time travel (oriented) stuff.
[Your Mother]: Gotta go. Stay out of trouble.
[LanX]: no worries ... mainland Europe is safe ;-P
[LanX]: ??? (probably my English is to limited)
[LanX]: too

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (11)
As of 2018-03-19 15:12 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (240 votes). Check out past polls.