I didn't know that map could be used such a way (i.e. having an output instead of altering every item in a list)
Erm, that is what map is for! :)
Perl::Critic even provides a ProhibitVoidMap
policy to warn you of code that uses map in void context.
I suggest you follow the simple stylistic advice given in
Effective Perl Programming in the item
"Use foreach, map and grep as appropriate" namely:
- Use foreach to iterate read-only over each element of a list
- Use map to create a list based on the contents of another list
- Use foreach to modify elements of a list
- Use grep to select elements in a list