I'm averse to for ()Why? The intended meaning of map is to create a new list from an old one. So modifying a set of values with map (rather than create a new set) is considered bad practice. You might do @h{@k} = map { stuff($_) } @h{@k} if you really want to avoid a for loop, or s/stuff/other/ for @h{@k}; if it's having multiple lines that bothers you.
Edit: when I say that modifying a set of values with map is considered bad practice, I'm talking about the inplace modification of elements, as in map { $_ += 2 } @numbers;, (or the dreaded "map in void context"). @h{@k} = map { stuff($_) } @h{@k} isn't as bad, as it actually builds a temporary new list, before overwriting the values in the hash. It's just neither the most straightforward way, nor the usual way. But as long as there's no inplace editing, that's fine IMHO.
In reply to Re: I want to operate on some values in a hash
by Eily
in thread I want to operate on some values in a hash
by misterperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |