"Perl Programmers Reference Guide (англ.) (программ.) /19.12.1998/ " - читать интересную книгу автора parenthesized parts of a regular expression are saved
under names containing only digits after the $ (see the _p_e_r_l_o_p manpage and the _p_e_r_l_r_e manpage). In addition, several special variables that provide windows into the inner working of Perl have names containing punctuation characters (see the _p_e_r_l_v_a_r manpage). Scalar values are always named with '$', even when referring to a scalar that is part of an array. It works like the English word "the". Thus we have: $days # the simple scalar value "days" $days[28] # the 29th element of array @days $days{'Feb'} # the 'Feb' value from hash %days $#days # the last index of array @days but entire arrays or array slices are denoted by '@', which works much like the word "these" or "those": @days # ($days[0], $days[1],... $days[n]) @days[3,4,5] # same as @days[3..5] @days{'a','c'} # same as ($days{'a'},$days{'c'}) PERLDATA(1) Perl Programmers Reference Guide PERLDATA(1) and entire hashes are denoted by '%': %days # (key1, val1, key2, val2 ...) In addition, subroutines are named with an initial '&', though this is optional when it's otherwise unambiguous (just as "do" is often redundant in English). Symbol table entries can be named with an initial '*', but you don't really care about that yet. Every variable type has its own namespace. You can, without fear of conflict, use the same name for a scalar variable, an array, or a hash (or, for that matter, a filehandle, a subroutine name, or a label). This means that $foo and @foo are two different variables. It also means that $foo[1] is a part of @foo, not a part of $foo. |
|
|