}

For a complete listing of the special variables, you should see the perlvar document that comes with your Perl distribution (such as in the perlvar manual page), or you can go online to http://theoryx5.uwinnipeg.ca/CPAN/perl/pod/perlvar.html.

Operators

Perl supports a number of operators to perform various operations. There are comparison operators (used to compare values, as the name implies), compound operators (used to combine operations or multiple comparisons), arithmetic operators (to perform math), and special string constants.

Comparison Operators

The comparison operators used by Perl are similar to those used by C, awk, and the csh shells, and are used to specify and compare values (including strings). Most frequently, a comparison operator is used within an if statement or loop. Perl has comparison opera tors for numbers and strings. Table 25.1 shows the numeric comparison operators and their behavior.

TABLE 25.1 Numeric Comparison Operators in Perl

Operator Meaning
== Is equal to
< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to
!= Not equal to
.. Range of >= first operand to <= second operand
<=> Returns -1 if less than, 0 if equal, and 1 if greater than

Table 25.2 shows the string comparison operators and their behaviors.

TABLE 25.2 String Comparison Operators in Perl

Operator Meaning
eq Is equal to
lt Less than
gt Greater than
le Less than or equal to
ge Greater than or equal to
ne Not equal to
Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

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

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