Operators and Comparators
Next: A Word about
Up:
Previous: Associative Arrays of
Perl's set of operators and comparators comprise nearly all of C's
operators and comparators. All of the usual arithmetic expressions and
precedence are the same in Perl as they are in C. Listed below are
expressions which are valid in Perl but not in C. These descriptions are
paraphrased from the Perl man page.
- **
- The exponentiation operator.
- **=
- The exponentiation assignment operator.
- ()
- The null list, used to initialize an array to null.
- .
- Concatenation of two strings.
- .=
- The concatenation assignment operator.
- eq
- String equality (== is numeric equality). Other
FORTRAN-style comparators are also available. These are only used on
strings.
- =~
- Certain operations search or modify the string $_ by default. This operator makes that kind of operation work on some
other string. The right argument is a search pattern, substitution, or
translation. The left argument is what is supposed to be searched,
substituted, or translated instead of the default $_.
- x
- The repetition operator.
- ..
- The range operator
- -f, -x, -l, ...
- Unary file test operator. Perl has the
ability to test various file permission settings in the same way as the
UNIX test command. Consult the Perl manual page for a full listing
of Perl file test operators.