We don't bite newbies here... much | |
PerlMonks |
Re: map vs for\foreach.by sn1987a (Deacon) |
on Mar 11, 2015 at 14:33 UTC ( [id://1119641]=note: print w/replies, xml ) | Need Help?? |
You are not comparing apples to apples. You map loop assigns (copies) the entire array in addition to incrementing each element. If you drop the assignment, map beats foreach. My results ----------------------- ------------------------
Note: It is generally considered poor form to use map only for its side effects. Updated to clean up and add note Update 2: More rigorous timing show that foreach is indeed faster --> Re^3: map vs for\foreach.
In Section
Seekers of Perl Wisdom
|
|