Decrements y by 1 and uses value (prefix decrement)
y-- Uses value of y and then decrements by 1 (postfix decrement)
x=y Assigns value of y to x. Perl also supports operator-assignment operators (+=, -=, *=, /=, %=, **=, and others)

You can also use comparison operators (such as == or <) and compound pattern operators (&&, ||, and !) in arithmetic statements. They evaluate to the value 0 for false and 1 for true.

Other Operators

Perl supports a number of operators that don't fit any of the prior categories. Table 25.5 summarizes these operators.

TABLE 25.5 Other Perl Operators

Operator Purpose
~x Bitwise not (changes 0 bits to 1 and 1 bits to 0)
x & y Bitwise and
x | y Bitwise or
x ^ y Bitwise exclusive or (XOR)
x << y Bitwise shift left (shifts x by y bits)
x >> y Bitwise shift right (shifts x by y bits)
x . y Concatenate y onto x
a x b Repeats string a for b number of times
x , y Comma operator — evaluates x and then y
x ? y : z Conditional expression — if x is true, y is evaluated; otherwise, z is evaluated.

Except for the comma operator and conditional expression, these operators can also be used with the assignment operator, similar to the way addition (+) can be combined with assignment (=), giving +=.

Special String Constants

Perl supports string constants that have special meaning or cannot be entered from the keyboard. Table 25.6 shows most of the constants supported by Perl.

TABLE 25.6 Perl Special String Constants

Expression Meaning
\ The means of including a backslash
a The alert or bell character
Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату