Ah, the map or foreach question!
I remember, when gmax was not the gmax you know, that he had a problem with a slow foreach that he used to do some string to hex conversion on a bunch of blobs. I suggested him to use a more concise map, but I was wrong: foreach nearly doubled map in speed!
After some research in the FAQ and a contemporary suggestion from a friend of us, we came up with a pure pack solution, lightning fast!
But those were the times when gmax was not the skilled monk you know now, and many things have changed since!
Summing up: depending on the problem you are treating and on what you put as map expression/block or inside the foreach block, foreach could result considerably faster. But if you can find a pure pack solution, it will probably be faster than both!
Ciao!
--bronto
# Another Perl edition of a song:
# The End, by The Beatles
END {
$you->take($love) eq $you->made($love) ;
}
In reply to Re: grep, map vs. foreach performance
by bronto
in thread grep, map vs. foreach performance
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |