typo fix
[p5sagit/p5-mst-13.2.git] / pod / perlop.pod
index 0f8117c..a7553df 100644 (file)
@@ -169,10 +169,10 @@ search or modify the string $_ by default.  This operator makes that kind
 of operation work on some other string.  The right argument is a search
 pattern, substitution, or transliteration.  The left argument is what is
 supposed to be searched, substituted, or transliterated instead of the default
-$_.  The return value indicates the success of the operation.  (If the
+$_.  The return value indicates the success of the operation.  If the
 right argument is an expression rather than a search pattern,
 substitution, or transliteration, it is interpreted as a search pattern at run
-time.  This can be is less efficient than an explicit search, because the
+time.  This can be less efficient than an explicit search, because the
 pattern must be compiled every time the expression is evaluated.
 
 Binary "!~" is just like "=~" except the return value is negated in
@@ -195,10 +195,11 @@ to the modulus operator as implemented by your C compiler.  This
 operator is not as well defined for negative operands, but it will
 execute faster.
 
-Binary "x" is the repetition operator.  In scalar context, 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 a list in parentheses, it repeats the list.
+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.
 
     print '-' x 80;            # print row of dashes
 
@@ -510,10 +511,10 @@ The following are recognized:
 Although these are grouped by family, they all have the precedence
 of assignment.
 
-Unlike in C, the assignment operator produces a valid lvalue.  Modifying
-an assignment is equivalent to doing the assignment and then modifying
-the variable that was assigned to.  This is useful for modifying
-a copy of something, like this:
+Unlike in C, the scalar assignment operator produces a valid lvalue.
+Modifying an assignment is equivalent to doing the assignment and
+then modifying the variable that was assigned to.  This is useful
+for modifying a copy of something, like this:
 
     ($tmp = $global) =~ tr [A-Z] [a-z];
 
@@ -526,6 +527,11 @@ is equivalent to
     $a += 2;
     $a *= 3;
 
+Similarly, a list assignment in list context produces the list of
+lvalues assigned to, and a list assignment in scalar context returns
+the number of elements produced by the expression on the right hand
+side of the assignment.
+
 =head2 Comma Operator
 
 Binary "," is the comma operator.  In scalar context it evaluates
@@ -620,9 +626,7 @@ function as operators, providing various kinds of interpolating and
 pattern matching capabilities.  Perl provides customary quote characters
 for these behaviors, but also provides a way for you to choose your
 quote character for any of them.  In the following table, a C<{}> represents
-any pair of delimiters you choose.  Non-bracketing delimiters use
-the same character fore and aft, but the 4 sorts of brackets
-(round, angle, square, curly) will all nest.
+any pair of delimiters you choose.  
 
     Customary  Generic        Meaning       Interpolates
        ''       q{}          Literal             no
@@ -634,6 +638,23 @@ the same character fore and aft, but the 4 sorts of brackets
                 s{}{}      Substitution          yes (unless '' is delimiter)
                tr{}{}    Transliteration         no (but see below)
 
+Non-bracketing delimiters use the same character fore and aft, but the four
+sorts of brackets (round, angle, square, curly) will all nest, which means
+that 
+
+       q{foo{bar}baz} 
+       
+is the same as 
+
+       'foo{bar}baz'
+
+Note, however, that this does not always work for quoting Perl code:
+
+       $s = q{ if($a eq "}") ... }; # WRONG
+
+is a syntax error. The C<Text::Balanced> module on CPAN is able to do this
+properly.
+
 There can be whitespace between the operator and the quoting
 characters, except when C<#> is being used as the quoting character.
 C<q#foo#> is parsed as the string C<foo>, while C<q #foo#> is the
@@ -658,6 +679,7 @@ a transliteration, the first eleven of these sequences may be used.
     \x1b       hex char        (ESC)
     \x{263a}   wide hex char   (SMILEY)
     \c[                control char    (ESC)
+    \N{name}   named char
 
     \l         lowercase next char
     \u         uppercase next char
@@ -667,7 +689,8 @@ a transliteration, the first eleven of these sequences may be used.
     \Q         quote non-word characters till \E
 
 If C<use locale> is in effect, the case map used by C<\l>, C<\L>, C<\u>
-and C<\U> is taken from the current locale.  See L<perllocale>.
+and C<\U> is taken from the current locale.  See L<perllocale>.  For
+documentation of C<\N{name}>, see L<charnames>.
 
 All systems use the virtual C<"\n"> to represent a line terminator,
 called a "newline".  There is no such thing as an unvarying, physical
@@ -940,7 +963,7 @@ notably if the result of qr() is used standalone:
        my @compiled = map qr/$_/i, @$patterns;
        grep {
            my $success = 0;
-           foreach my $pat @compiled {
+           foreach my $pat (@compiled) {
                $success = 1, last if /$pat/;
            }
            $success;
@@ -1051,9 +1074,9 @@ this expression:
 
     qw(foo bar baz)
 
-is exactly equivalent to the list:
+is semantically equivalent to the list:
 
-    ('foo', 'bar', 'baz')
+    'foo', 'bar', 'baz'
 
 Some frequently seen examples: