in reply to using map

You could set an array using something like that, but if you want to add extra stuff to the end of the array (that's what push does) you actually need to use push.

Use grep to select elements from a list. Although it is possible to abuse map in the way you showed to achieve that it really isn't what map is about.

$list is not a list (except in the degenerate sense of a list with only one element), it is a scalar. It may be that it is a reference to an array, but in that case you'd need to write @$list to make the referenced list of elements available for a grep or map.

If you have some code that isn't doing what you expect, how about you show us a runnable sample script to illustrate the problem? Combining the code snippet you show and your question you seem to have at least three misunderstandings about what is going on in relation to that code!

True laziness is hard work