![]() When executed, this will produce the following result − Other Perl will understand it as a variable and will print its value. Here we have used the escape sign (\) before the $ sign just to print it. The following table lists all operators from highest precedence to lowest.Live = (25, 30, = ("John Paul", "Lisa", "Kumar") The arrow operator is mostly used in dereferencing a method or variable from an object or a class nameĮxample − $obj->$a is an example to access variable $a from object $obj. returns a list of values counting (up by ones) from the left value to the right valueĪuto Increment operator increases integer value by oneĪuto Decrement operator decreases integer value by one The repetition operator x returns a string consisting of the left operand repeated the number of times specified by the right operand. Assume variable a holds 10 and variable b holds 20 then −īinary operator dot (.) concatenates two strings.Įxample − If $a = "abc", $b = "def" then $a.$b will give "abcdef" There are following miscellaneous operators supported by Perl language. In the following table, a represents any pair of delimiters you choose. There are following Quote-like operators supported by Perl language. If a condition is true then Logical NOT operator will make false. Use to reverses the logical state of its operand. If any of the two operands are non zero then then condition becomes true.Ĭ-style Logical OR operator copies a bit if it exists in eather operand.Ĭalled Logical NOT Operator. If both the operands are true then then condition becomes true.Ĭ-style Logical AND operator copies a bit to the result if it exists in both operands.Ĭalled Logical OR Operator. Assume variable $a holds true and variable $b holds false then −Ĭalled Logical AND operator. There are following logical operators supported by Perl language. The left operands value is moved right by the number of bits specified by the right operand.Įxample − $a > 2 will give 15 which is 0000 1111 Assume variable $a holds 10 and variable $b holds 20 then, lets check the following numeric equality operators −Ĭhecks if the value of two operands are equal or not, if yes then condition becomes true.Ĭhecks if the value of two operands are equal or not, if values are not equal then condition becomes true.Ĭhecks if the value of two operands are equal or not, and returns -1, 0, or 1 depending on whether the left argument is numerically less than, equal to, or greater than the right argument.Ĭhecks if the value of left operand is greater than the value of right operand, if yes then condition becomes true.Ĭhecks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true.īinary Right Shift Operator. ![]() These are also called relational operators. ![]() Performs exponential (power) calculation on operatorsĮxample − $a**$b will give 10 to the power 20 Multiplies values on either side of the operatorĭivides left hand operand by right hand operandĭivides left hand operand by right hand operand and returns remainder Subtracts right hand operand from left hand operand ![]() Perl Arithmetic OperatorsĪssume variable $a holds 10 and variable $b holds 20, then following are the Perl arithmatic operators −Īdds values on either side of the operator Lets have a look at all the operators one by one. Perl language supports many operator types, but following is a list of important and most frequently used operators − Here 4 and 5 are called operands and is called operator. ![]() Simple answer can be given using the expression 4 5 is equal to 9. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |