8/14/2019 Perl Operators.doc
1/2
Perl Operators
Perl categorizes operators into two varieties. One for strings and the other for numericvariables.
String Operators
x - The returned string is the string on the left side of the operand repeated the
amount of times indicated by the right operand.
. - Appends one string to another.
, - valuates the left operand, then the right operand and returns the result of the
right operand!
"" - #ncrements the string by one value. The string $abc$ would become $abd$.
cmp - #f the left string is less than, e%ual to, or greater than the right string, the
values -&, ', or & are returned, respectively.
e% - True if the two strings are e%ual. ge - True if the left string is greater than or e%ual to the right string.
gt - True if the left string is greater than the right string.
le - True if the left string is less than or e%ual to the right string.
lt - True if the left string is less than the right string.
ne - True if the two strings are not the same.
Numeric Operators
" - Adds two operands.
- - (ubtracts one operand from another.
) - *ultiplies two operands. + - ivides one operand by another returning the %uotient.
- ivides one operand by another returning the remainder modulus/.
00 - 1ompares two operands, returning a boolean value of true if they are e%ual.
20 - 1ompares two operands, returning a boolean value of true if they are not
e%ual.
30 - 1ompares two operands returning a boolean value of true if the left operand
is less than or equalto the right operand.
3 - 4ess than comparison returning a boolean true value if the operand on the left
is less than the one on the right.
50 - 1ompares two operands returning a boolean value of true if the left operand
is greater than or equalto the right operand.
305 - A value of -&, "&, or ' is returned if the left operand is less than, greater
than, or e%ual to the operand on the right respectively.
66 - 4ogical A7.
88 - 4ogical O9.
6 - :itwise A7.
8 - :itwise O9.
8/14/2019 Perl Operators.doc
2/2
; - :itwise xx? is > times >
times >.
"0 - The value on the right is added to the value on the left. The expression a 0a"b is the same as a"0b.
-0 - The value on the right is subtracted from the value on the left. The expression
a 0 a-b is the same as a-0b.
x0 - The expression a0axb is the same as ax0b.
55 - :itwise shift shifting the bits in the left operand to the right by the number of
bits indicated by the right operand. 33 - :itwise shift shifting the bits in the left operand to the left by the number of
bits indicated by the right operand.
; - Ones complement.
Top Related