Perl Operator Types
Perl operators provide values to their operands like numeric, Boolean or string, etc. To choose an appropriate operator, you need to know the value of operands.
We'll discuss following type of operators:
Perl Numeric operators
Numeric operators are the standard arithmetic operators like addition (+), subtraction (-), multiplication (*), division (/) and modulo (%), etc.
Perl String operators
String operators are positive and negative regular expression with repetition (=~ and !~) and concatenation ( .).
String Concatenation operator
Hello this is JavaTpoint.
String Repetition operator
Thank You Thank You Thank You.
Here, note that on the right of 'x' it must be an integer.
There should be space on either side of the 'x' operator.
Perl Logical operators
Logical operators give a Boolean value to their operands. They are (&&, || and or).
&& -> In && operator, if $a is 0, then value of $a && $b must be false irrespective of the value of $b. So perl does not bother to check $b value. This is called short-circuit evaluation.
|| -> In || operator, if $a is non-zero, then value of $a && $b must be true irrespective of the value of $b. So perl does not bother to check $b value.
Perl Bitwise operators
Bitwise operators treat their operands numerically at bit level. These are (<<, >>, &, |, ^, <<=, >>=, &=, |=, ^=).
Every number will be denoted in terms of 0s and 1s. Initially integers will be converted into binary bit and result will be evaluated. Final result will be displayed in the integer form.
127 96 31 15
Perl Special operators
The auto-increment (++) operator is a special operator that increments the numeric character itself by 1.
Perl Comparison operators
The comparison operator compares the values of its operands. These are ( ==, <, <=, >, >=, <=>, !=).
Enter your salary: 15000 You are not earning well
Perl Assignment operators
The assignment operator assigns a value to a variable.
These are (=, +=, -=, *=, /=, |=, &=, %=)
40 30 30 10