What is the syntax used in Perl grep function?


The syntax used in Perl is

a) grep BlOCK LIST

b) grep ( EXPR, LIST )

  • BLOCK: It contains one or more statements delimited by braces, the last statement determines in the block whether the block will be evaluated true or false.
  • EXPR: It represents any expression that supports $, particularly a regular expression. Against each element of the list, expression is applied, and if the result of the evaluation is true, the current element will be attached to the returned list
  • LIST: It is a list of elements or an array


© 2017