Perl
Operators
Perl categorizes operators into
two varieties. One for strings and
the other for numeric variables.
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.
- , - Evaluates the left
operand, then the right operand
and returns the result of the
right operand?
- ++ - Increments the string
by one value. The string "abc"
would become "abd".
- cmp - If the left string is
less than, equal to, or greater
than the right string, the
values -1, 0, or 1 are returned,
respectively.
- eq - True if the two strings
are equal.
- ge - True if the left string
is greater than or equal 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 equal 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.
- - - Subtracts one operand
from another.
- × - Multiplies two operands.
- ÷ - Divides one operand
by another returning the quotient.
- % - Divides one operand
by another returning the remainder
(modulus).
- == - Compares two operands,
returning a boolean value
of true if they are equal.
- != - Compares two operands,
returning a boolean value
of true if they are not equal.
- <= - Compares two operands
returning a boolean value
of true if the left operand
is less
than or equal to
the right operand.
- < - Less than comparison
returning a boolean true value
if the operand on the left
is less than the one on the
right.
- >= - Compares two operands
returning a boolean value
of true if the left operand
is greater
than or equal to
the right operand.
- <=> - A value of -1,
+1, or 0 is returned if the
left operand is less than,
greater than, or equal to
the operand on the right respectively.
- && - Logical AND.
- || - Logical OR.
- & - Bitwise AND.
- | - Bitwise OR.
- ~ - Bitwise XOR (exclusive
OR).
- ++ - Increment the value
by 1.
- -- Decrement the value by
1.
- xx - The left operand is
taken to the power of the
right operand. 5xx3 is 5 times
5 times 5.
- += - The value on the right
is added to the value on the
left. The expression a = a+b
is the same as a+=b.
- -= - The value on the right
is subtracted from the value
on the left. The expression
a = a-b is the same as a-=b.
- x= - The expression a=axb
is the same as ax=b.
- >> - Bitwise shift
shifting the bits in the left
operand to the right by the
number of bits indicated by
the right operand.
- << - Bitwise shift
shifting the bits in the left
operand to the left by the
number of bits indicated by
the right operand.
- ~ - Ones complement.
|
|
|
|