Regular Expressions
The Grep Function

  • The grep() function applies EXPR (a literal value or regular expression) to each element in LIST and returns the elements which match EXPR

      @myList = grep( EXPR, LIST );

  • For example, given a list @bar containing lines from a Perl script, we could strip comment lines using

      @foo = grep( !/^#/, @bar );