in reply to question for perl book & magazine authors
I'm convinced that map & grep aren't as heavily used as they could be because people don't understand them.
I don't think I agree with the implied premise that map() and grep() should be used more heavily. I'd say they are probably used inappropriately at least as often as appropriate uses for them are missed.
For instance, in the example you gave, you'd probably be better off using a hash to determine common elements.
Update: You should also be more careful to check your benchmarks for correctness. Your "using grep" benchmark doesn't even reference @array1...
Update 2: I also just noticed you are using grep in a scalar context in the unless clause in your "using foreach" sub. That's one of those inappropriate uses of grep I mentioned above...
-sauoq "My two cents aren't worth a dime.";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: question for perl book & magazine authors
by holli (Abbot) on Oct 19, 2005 at 21:06 UTC | |
by sauoq (Abbot) on Oct 19, 2005 at 21:18 UTC |
In Section
Seekers of Perl Wisdom