Ubuntu Unleashed 2019 Edition: Covering 18.04, 18.10, 19.04

(singke) #1
> Greater   than

<= Less than    or  equal   to

>= Greater  than    or  equal   to

<=> Returns –1  if  less    than,    0  if  equal   to, and  1  if  greater than

!= Not  equal   to

.. Range    of  >=  first   operand to  <=  second  operand

Table 46.2 shows the string comparison operators and their meanings.


Table 46.2 String Comparison Operators in Perl


OperatorMeaning

eq Is   equal   to

lt Less than

gt Greater  than

le Less than    or  equal   to

ge Greater  than    or  equal   to

ne Not  equal   to

cmp Returns -1  if  less    than,    0  if  equal   to, and  1  if  greater than

=~ Matched  by  regular expression

!~ Not  matched by  regular expression

Compound Operators


Perl uses compound operators, similar to those used by C or awk, which can
be used to combine other operations (such as comparisons or arithmetic) into
more complex forms of logic. Table 46.3 shows the compound pattern

Free download pdf