nonassoc list operators (rightward)
right not
left and
- left or xor err
+ left or xor
In the following sections, these operators are covered in precedence order.
starts with a plus or minus, a string starting with the opposite sign
is returned. One effect of these rules is that -bareword is equivalent
to the string "-bareword". If, however, the string begins with a
-non-alphabetic character (exluding "+" or "-"), Perl will attempt to convert
+non-alphabetic character (excluding "+" or "-"), Perl will attempt to convert
the string to a numeric and the arithmetic negation is performed. If the
string cannot be cleanly converted to a numeric, Perl will give the warning
B<Argument "the string" isn't numeric in negation (-) at ...>.
Binary "/" divides two numbers.
X</> X<slash>
-Binary "%" computes the modulus of two numbers. Given integer
+Binary "%" is the modulo operator, which computes the division
+remainder of its first argument with respect to its second argument.
+Given integer
operands C<$a> and C<$b>: If C<$b> is positive, then C<$a % $b> is
-C<$a> minus the largest multiple of C<$b> that is not greater than
+C<$a> minus the largest multiple of C<$b> less than or equal to
C<$a>. If C<$b> is negative, then C<$a % $b> is C<$a> minus the
smallest multiple of C<$b> that is not less than C<$a> (i.e. the
result will be less than or equal to zero). If the operands
If the absolute value of the right operand (C<abs($b)>) is greater than
or equal to C<(UV_MAX + 1)>, "%" computes the floating-point remainder
C<$r> in the equation C<($r = $a - $i*$b)> where C<$i> is a certain
-integer that makes C<$r> should have the same sign as the right operand
+integer that makes C<$r> have the same sign as the right operand
C<$b> (B<not> as the left operand C<$a> like C function C<fmod()>)
and the absolute value less than that of C<$b>.
Note that when C<use integer> is in scope, "%" gives you direct access
-to the modulus operator as implemented by your C compiler. This
+to the modulo operator as implemented by your C compiler. This
operator is not as well defined for negative operands, but it will
execute faster.
-X<%> X<remainder> X<modulus> X<mod>
+X<%> X<remainder> X<modulo> X<mod>
Binary "x" is the repetition operator. In scalar context or if the left
operand is not enclosed in parentheses, it returns a string consisting
Binary "~~" does a smart match between its arguments. Smart matching
is described in L<perlsyn/"Smart matching in detail">.
-This operator is only available if you enable the "~~" feature:
-see L<feature> for more information.
X<~~>
"lt", "le", "ge", "gt" and "cmp" use the collation (sort) order specified
@a = scalar(@b) || @c; # really meant this
@a = @b ? @b : @c; # this works fine, though
-As more readable alternatives to C<&&>, C<//> and C<||> when used for
-control flow, Perl provides C<and>, C<err> and C<or> operators (see below).
-The short-circuit behavior is identical. The precedence of "and", "err"
+As more readable alternatives to C<&&> and C<||> when used for
+control flow, Perl provides the C<and> and C<or> operators (see below).
+The short-circuit behavior is identical. The precedence of "and"
and "or" is much lower, however, so that you can safely use them after a
list operator without the need for parentheses:
expression is evaluated only if the left expression is true.
=head2 Logical or, Defined or, and Exclusive Or
-X<operator, logical, or> X<operator, logical, xor> X<operator, logical, err>
+X<operator, logical, or> X<operator, logical, xor>
X<operator, logical, defined or> X<operator, logical, exclusive or>
-X<or> X<xor> X<err>
+X<or> X<xor>
Binary "or" returns the logical disjunction of the two surrounding
expressions. It's equivalent to || except for the very low precedence.
Then again, you could always use parentheses.
-Binary "err" is equivalent to C<//>--it's just like binary "or", except it
-tests its left argument's definedness instead of its truth. There are two
-ways to remember "err": either because many functions return C<undef> on
-an B<err>or, or as a sort of correction: C<$a = ($b err 'default')>. This
-keyword is only available when the 'err' feature is enabled: see
-L<feature> for more information.
-
Binary "xor" returns the exclusive-OR of the two surrounding expressions.
It cannot short circuit, of course.
expression. I<STRING> is interpolated the same way as I<PATTERN>
in C<m/PATTERN/>. If "'" is used as the delimiter, no interpolation
is done. Returns a Perl value which may be used instead of the
-corresponding C</STRING/imosx> expression. The returned value is a
+corresponding C</STRING/msixpo> expression. The returned value is a
normalized version of the original pattern. It magically differs from
-a string containing the same characters: ref(qr/x/) returns "Regexp",
+a string containing the same characters: C<ref(qr/x/)> returns "Regexp",
even though dereferencing the result returns undef.
For example,