perl operators
Perl has a wide variety of operators, including:
- Arithmetic operators:
- Addition: +
- Subtraction: -
- Multiplication: *
- Division: /
- Modulus: %
- Exponentiation: **
- Assignment operators:
- Simple assignment: =
- Compound assignment: +=, -=, *=, /=, %=, **=
- Comparison operators:
- Equality: ==
- Inequality: !=
- Greater than: >
- Less than: <
- Greater than or equal to: >=
- Less than or equal to: <=
- String comparison: eq, ne, gt, lt, ge, le
- Logical operators:
- Logical AND: &&
- Logical OR: ||
- Logical NOT: !
- Bitwise operators:
- Bitwise AND: &
- Bitwise OR: |
- Bitwise XOR: ^
- Bitwise NOT: ~
- Left shift: <<
- Right shift: >>
- Conditional operators:
- Ternary operator: ?:
- Defined-or operator: // (introduced in Perl 5.10)
- Regular expression operators:
- Match operator: =~
- Negated match operator: !~
- Substitution operator: s///
- Transliteration operator: tr///
- Range operators:
- Range operator: ..
- Exclusive range operator: ...
- List operators:
- List concatenation: .
- Array slice: @array[start..end]
- List assignment: ($var1, $var2) = (1, 2)
- File test operators:
- Existence test: -e
- File type test: -f, -d, -l, -p, -S, -b, -c
- File permission test: -r, -w, -x, -o, -R, -W, -X
These are just some of the many operators available in Perl.