in reply to Map and Grep

Here's a quick explanation of the difference between map and grep:

map EXPR, list
For each element in LIST, map executes EXPR; the result of EXPR is added to the return list.
grep EXPR, list
For each element in LIST, grep executes EXPR; if EXPR returned true, the value of $_ is added to the return list, otherwise nothing is added to the return list.

grep EXPR, list can be written as map { EXPR ? $_ : ()} LIST , and
map EXPR, list can be written as grep { $_ = EXPR; 1 } @tmp = LIST (@tmp is necessary because assigning to $_ inside a grep or map changes the original array.)