Seanie wrote:
> Rob Dixon wrote:
>>> map(s/$find/$replace/, @arr);
>> Haha yes you can, but if you want to write nasty code go for
>>   grep s/$find/$replace/, @arr;
>> which also works.
> 
> True, but grep implies "find stuff", while map implies "do stuff", so your 
> nasty code is way, way, nastier than mine - it masks the intention.
> 
> Maybe using map in void context is deep-level wrongness, but it'd be nice if 
> somebody would explain WHY, instead of posting "don't do it" one-liners. 

perldoc perl581delta
[ snip ]
       Miscellaneous Enhancements

       "map" in void context is no longer expensive. "map" is now context
       aware, and will not construct a list if called in void context.


So it is not really "wrong" anymore (for certain values of "wrongness".)



John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to