What's the difference between grep and map in Perl?

前端 未结 6 774
逝去的感伤
逝去的感伤 2020-12-31 06:50

In Perl both grep and map take an expression and a list, and evaluate the expression for each element of the list.

What is the difference b

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-31 07:11

    Facetiously: grep gives its block scalar context, map gives its block list context. (And BLOCK foreach LIST gives its block void context.)

提交回复
热议问题