X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperlop.pod;h=ba2ff9f73771a443e8b79e7bff59ceb543d355bd;hb=0d594e51e853b48a97327618a6e01007b612c5cd;hp=17cf9a757845cd961fd2bdcd32d016e1febb8599;hpb=bff5667cab927076651176299f898dee445d6b01;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/perlop.pod b/pod/perlop.pod index 17cf9a7..ba2ff9f 100644 --- a/pod/perlop.pod +++ b/pod/perlop.pod @@ -191,7 +191,7 @@ the operand is an identifier, a string consisting of a minus sign concatenated with the identifier is returned. Otherwise, if the string 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 "-bareword". +to the string "-bareword". Unary "~" performs bitwise negation, i.e., 1's complement. For example, C<0666 & ~027> is 0640. (See also L and @@ -219,7 +219,8 @@ pattern, substitution, or transliteration. The left argument is what is supposed to be searched, substituted, or transliterated instead of the default $_. When used in scalar context, the return value generally indicates the success of the operation. Behavior in list context depends on the particular -operator. See L for details. +operator. See L for details and +L for examples using these operators. If the right argument is an expression rather than a search pattern, substitution, or transliteration, it is interpreted as a search pattern at run @@ -249,9 +250,9 @@ Binary "x" is the repetition operator. In scalar context or if the left operand is not enclosed in parentheses, it returns a string consisting of the left operand repeated the number of times specified by the right operand. In list context, if the left operand is enclosed in -parentheses, it repeats the list. If the right operand is zero or -negative, it returns an empty string or an empty list, depending on the -context. +parentheses or is a list formed by C, it repeats the list. +If the right operand is zero or negative, it returns an empty string +or an empty list, depending on the context. print '-' x 80; # print row of dashes @@ -687,9 +688,30 @@ In list context, it's just the list argument separator, and inserts both its arguments into the list. The C<< => >> operator is a synonym for the comma, but forces any word -to its left to be interpreted as a string (as of 5.001). It is helpful -in documenting the correspondence between keys and values in hashes, -and other paired elements in lists. +(consisting entirely of word characters) to its left to be interpreted +as a string (as of 5.001). This includes words that might otherwise be +considered a constant or function call. + + use constant FOO => "something"; + + my %h = ( FOO => 23 ); + +is equivalent to: + + my %h = ("FOO", 23); + +It is I: + + my %h = ("something", 23); + +If the argument on the left is not a word, it is first interpreted as +an expression, and then the string value of that is used. + +The C<< => >> operator is helpful in documenting the correspondence +between keys and values in hashes, and other paired elements in lists. + + %hash = ( $key => $value ); + login( $username => $password ); =head2 List Operators (Rightward) @@ -1378,9 +1400,9 @@ Examples: \*/ # Match the closing delimiter. } []gsx; - s/^\s*(.*?)\s*$/$1/; # trim white space in $_, expensively + s/^\s*(.*?)\s*$/$1/; # trim whitespace in $_, expensively - for ($variable) { # trim white space in $variable, cheap + for ($variable) { # trim whitespace in $variable, cheap s/^\s+//; s/\s+$//; } @@ -1646,6 +1668,11 @@ Because the slash that terminated C was followed by a C, the example above is not C, but rather C with no C modifier. So the embedded C<#> is interpreted as a literal C<#>. +Also no attention is paid to C<\c\> during this search. +Thus the second C<\> in C is interpreted as a part of C<\/>, +and the following C is not recognized as a delimiter. +Instead, use C<\034> or C<\x1c> at the end of quoted constructs. + =item Removal of backslashes before delimiters During the second pass, text between the starting and ending @@ -1982,7 +2009,8 @@ depending on context. This distinction is determined on syntactic grounds alone. That means C<< <$x> >> is always a readline() from an indirect handle, but C<< <$hash{key}> >> is always a glob(). That's because $x is a simple scalar variable, but C<$hash{key}> is -not--it's a hash element. +not--it's a hash element. Even C<< <$x > >> (note the extra space) +is treated as C, not C. One level of double-quote interpretation is done first, but you can't say C<< <$foo> >> because that's an indirect filehandle as explained