25.5. Calculations and Operators

Perl supports the standard operators for its various data types. The following tables outline the basic operators available in Perl.

Perl Arithmetic Operators

OperatorUse
+Addition
-Subtraction
*Multiplication
/Division
%Modulus
**Exponent
++Increment
--Decrement

Perl Assignment Operators

OperatorUse
=Assignment
+=Increment assignment
-=Decrement assignment
*=Multiplication assignment
/=Division assignment
%=Modulus assignment
**=Exponential assignment
.=String concatenation assignment

Perl Comparison Operators

OperatorUse
==Numeric is equal to
!=Numeric is not equal to
>Numeric is greater than
<Numeric is less than
>=Numeric is greater than or equal to
<=Numeric is less than or equal to
eqString equality
neString nonequality
gtString greater than
ltString less than
geString greater than or equal to
leString less than or equal to

Perl Logical Operators

OperatorUse
&&And
||Or
!Not

Perl Bitwise Operators

OperatorUse
&And
|Or
^Xor
~Not
<<Left shift
>>Right shift

Perl Miscellaneous Operators

OperatorUse
.Object/property/method separator
?Condition operator
deleteDelete specified object
newCreate new object
thisReference current object
refType of object (number, string, and so on)
voidEvaluate expression without return value

String Operators

OperatorUse
.Concatenation
xRepetition

String Tokens

TokenCharacter
\bBackspace
\eEscape
\tHorizontal Tab
\nLine feed
\vVertical Tab
\fForm feed
\rCarriage return
\"Double quote
\'Single quote
\$Dollar sign
\@At sign
\\Backslash

Get Web Standards Programmer's Reference: HTML, CSS, JavaScript®, Perl, Python®, and PHP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.