Questions about this topic? Sign up to ask in the talk tab.

Difference between revisions of "Perl/Basics/Boolean Logic/Operators/Regular Expressions"

From NetSec
Jump to: navigation, search
(Created page with "The '''~''' operator is used with regular expressions, which are covered later in this article. The ~ operator can be used in a variety of ways: * '''=~''' * '''!~''' Regular ex...")
 
 
(No difference)

Latest revision as of 02:05, 19 July 2012

The ~ operator is used with regular expressions, which are covered later in this article. The ~ operator can be used in a variety of ways:

  • =~
  • !~

Regular expressions can also be very useful when using perl as a shell glue language. As an example:

"find | perl -nwl -e "m:zs: and print" 

will pipe the output of the find command into perl, which will then apply the regular expression m:zs: which is an expression which only looks for those two characters in those orders. The use of "and" makes perl only apply the print operation to the line if the first match returns a "true." The use of -nwl means that newlines are stripped, warnings are enabled, and that the input which doesn't match isn't printed as well.