in reply to Re: When should I use map, for?
in thread When should I use map, for?

I am using 5.8.6, so the delay shouldn't be a "recent fix" thing. Also, while tr/// would work for this particular case, the live-code version is not a transliteration.

The Eightfold Path: 'use warnings;', 'use strict;', 'use diagnostics;', perltidy, CGI or CGI::Simple, try the CPAN first, big modules and small scripts, test first.

Replies are listed 'Best First'.
Re^3: When should I use map, for?
by Transient (Hermit) on May 19, 2005 at 21:13 UTC
    Understood. I've noticed similar benchmark results when I ran your test. Perhaps what I am vaguely recalling is a "narrowing of the gap", so to speak.

    I refer back to my original post about when to use map vs. foreach. In this case, where it is executing many many times, it will make a difference. However, in the bulk of my coding, I use one or the other when it makes sense (primarily in a list vs. void context) and worry about performance later. I don't believe there is a time where, all other things being equal, map will be faster than foreach. I could be completely off the mark on this, however.