Questions about this topic? Sign up to ask in the talk tab.
Perl/Basics/Boolean Logic/Operators/Regular Expressions
From NetSec
(Redirected from Perl regular expression operator)
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.