From: Seanie <[EMAIL PROTECTED]> > 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.
Well, because it's "for" that implies "do stuff". "map" means "transform stuff and give me the results". With a "for" I expect that the work will be done as a side-effect, with "map" I expect that the code block will be side-effect free. That it will get a value and produce a value (or values). Sure, it may make sense to produce a value and do something more at the same time, but the produced value should be the main result. Jenda ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/