t/op/grep.t using test.pl
[p5sagit/p5-mst-13.2.git] / pod / perlop.pod
index d0b4c64..4c3d919 100644 (file)
@@ -41,7 +41,7 @@ values only, not array values.
     left       << >>
     nonassoc   named unary operators
     nonassoc   < > <= >= lt gt le ge
-    nonassoc   == != <=> eq ne cmp
+    nonassoc   == != <=> eq ne cmp ~~
     left       &
     left       | ^
     left       &&
@@ -199,7 +199,11 @@ 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 the string "-bareword".
+to the string "-bareword".  If, however, the string begins with a
+non-alphabetic character (exluding "+" or "-"), Perl will attempt to convert
+the string to a numeric and the arithmetic negation is performed. If the
+string cannot be cleanly converted to a numeric, Perl will give the warning
+B<Argument "the string" isn't numeric in negation (-) at ...>.
 X<-> X<negation, arithmetic>
 
 Unary "~" performs bitwise negation, i.e., 1's complement.  For
@@ -426,6 +430,12 @@ argument is stringwise less than, equal to, or greater than the right
 argument.
 X<cmp>
 
+Binary "~~" does a smart match between its arguments. Smart matching
+is described in L<perlsyn/"Smart Matching in Detail">.
+This operator is only available if you enable the "~~" feature:
+see L<feature> for more information.
+X<~~>
+
 "lt", "le", "ge", "gt" and "cmp" use the collation (sort) order specified
 by the current locale if C<use locale> is in effect.  See L<perllocale>.
 
@@ -578,9 +588,12 @@ As a scalar operator:
 
     if (101 .. 200) { print; } # print 2nd hundred lines, short for
                                #   if ($. == 101 .. $. == 200) ...
-    next line if (1 .. /^$/);  # skip header lines, short for
+
+    next LINE if (1 .. /^$/);  # skip header lines, short for
                                #   ... if ($. == 1 .. /^$/);
-    s/^/> / if (/^$/ .. eof());        # quote body
+                               # (typically in a loop labeled LINE)
+
+    s/^/> / if (/^$/ .. eof());  # quote body
 
     # parse mail messages
     while (<>) {
@@ -603,16 +616,14 @@ the two range operators:
               "1  - Baz",
               "   - Quux");
 
-    foreach(@lines)
-    {
-        if (/0/ .. /1/)
-        {
+    foreach (@lines) {
+        if (/0/ .. /1/) {
             print "$_\n";
         }
     }
 
-This program will print only the line containing "Bar". If 
-the range operator is changed to C<...>, it will also print the 
+This program will print only the line containing "Bar". If
+the range operator is changed to C<...>, it will also print the
 "Baz" line.
 
 And now some examples as a list operator:
@@ -705,9 +716,9 @@ might trigger, such as from tie().  Other assignment operators work similarly.
 The following are recognized:
 
     **=    +=    *=    &=    <<=    &&=
-           -=    /=    |=    >>=    ||=    
-           .=    %=    ^=           //= 
-                x=
+           -=    /=    |=    >>=    ||=
+           .=    %=    ^=           //=
+                 x=
 
 Although these are grouped by family, they all have the precedence
 of assignment.
@@ -741,7 +752,8 @@ its left argument, throws that value away, then evaluates its right
 argument and returns that value.  This is just like C's comma operator.
 
 In list context, it's just the list argument separator, and inserts
-both its arguments into the list.
+both its arguments into the list.  These arguments are also evaluated
+from left to right.
 
 The C<< => >> operator is a synonym for the comma, but forces any word
 (consisting entirely of word characters) to its left to be interpreted
@@ -825,10 +837,12 @@ takes higher precedence.
 
 Then again, you could always use parentheses.
 
-Binary "err" is equivalent to C<//>--it's just like binary "or", except it tests
-its left argument's definedness instead of its truth.  There are two ways to 
-remember "err":  either because many functions return C<undef> on an B<err>or,
-or as a sort of correction:  C<$a=($b err 'default')>
+Binary "err" is equivalent to C<//>--it's just like binary "or", except it
+tests its left argument's definedness instead of its truth.  There are two
+ways to remember "err":  either because many functions return C<undef> on
+an B<err>or, or as a sort of correction:  C<$a = ($b err 'default')>. This
+keyword is only available when the 'err' feature is enabled: see
+L<feature> for more information.
 
 Binary "xor" returns the exclusive-OR of the two surrounding expressions.
 It cannot short circuit, of course.
@@ -867,7 +881,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.  
+any pair of delimiters you choose.
 
     Customary  Generic        Meaning       Interpolates
        ''       q{}          Literal             no
@@ -884,11 +898,11 @@ any pair of delimiters you choose.
 
 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 
+that
 
-       q{foo{bar}baz} 
+       q{foo{bar}baz}
 
-is the same as 
+is the same as
 
        'foo{bar}baz'
 
@@ -2252,7 +2266,7 @@ L<Bitwise String Operators>.)  However, C<use integer> still has meaning for
 them.  By default, their results are interpreted as unsigned integers, but
 if C<use integer> is in effect, their results are interpreted
 as signed integers.  For example, C<~0> usually evaluates to a large
-integral value.  However, C<use integer; ~0> is C<-1> on twos-complement
+integral value.  However, C<use integer; ~0> is C<-1> on two's-complement
 machines.
 
 =head2 Floating-point Arithmetic