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

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

From NetSec
Jump to: navigation, search
Line 1: Line 1:
 
====Mathematical====
 
====Mathematical====
{{:Perl/Basics/Boolean_Logic/Operators/Mathematical}}
+
{{:Perl/Basics/Boolean_Logic/Operators/Mathematic}}
 
====Regular Expressions====
 
====Regular Expressions====
 
{{:Perl/Basics/Boolean_Logic/Operators/Regular_Expressions}}
 
{{:Perl/Basics/Boolean_Logic/Operators/Regular_Expressions}}

Revision as of 01:10, 19 July 2012

Mathematical

Perl/Basics/Boolean Logic/Operators/Mathematic

Regular Expressions

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.