per Larry's idea, parse 1.2.3 as v1.2.3; C<require 5.6.0> and
[p5sagit/p5-mst-13.2.git] / pod / perlop.pod
index 6c2cb33..bc6f2ce 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
 
@@ -220,15 +221,11 @@ Binary "." concatenates two strings.
 
 Binary "<<" returns the value of its left argument shifted left by the
 number of bits specified by the right argument.  Arguments should be
-integers.  (See also L<Integer Arithmetic>.)  Shifting more than the
-width of an integer in bits (usually 32 or 64) produces undefined
-(platform dependent) results.
+integers.  (See also L<Integer Arithmetic>.)
 
 Binary ">>" returns the value of its left argument shifted right by
 the number of bits specified by the right argument.  Arguments should
-be integers.  (See also L<Integer Arithmetic>.)  Shifting more than
-the width of an integer in bits (usually 32 or 64) produces undefined
-(platform dependent) results.
+be integers.  (See also L<Integer Arithmetic>.)
 
 =head2 Named Unary Operators
 
@@ -365,7 +362,7 @@ With the C-style operators that would have been written like this:
     unlink("alpha", "beta", "gamma")
            || (gripe(), next LINE);
 
-Use "or" for assignment is unlikely to do what you want; see below.
+Using "or" for assignment is unlikely to do what you want; see below.
 
 =head2 Range Operators
 
@@ -514,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];
 
@@ -530,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
@@ -787,7 +789,7 @@ the trailing delimiter.  This avoids expensive run-time recompilations,
 and is useful when the value you are interpolating won't change over
 the life of the script.  However, mentioning C</o> constitutes a promise
 that you won't change the variables in the pattern.  If you change them,
-Perl won't even notice.  See also L<qr//>.
+Perl won't even notice.  See also L<"qr//">.
 
 If the PATTERN evaluates to the empty string, the last
 I<successfully> matched regular expression is used instead.
@@ -961,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;
@@ -1072,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:
 
@@ -1800,6 +1802,22 @@ operation you intend by using C<""> or C<0+>, as in the examples below.
 See L<perlfunc/vec> for information on how to manipulate individual bits
 in a bit vector.
 
+=head2 Strings of Character
+
+A literal of the form C<v1.20.300.4000> is parsed as a string composed
+of characters with the specified ordinals.  This provides an alternative,
+more readable way to construct strings, rather than use the somewhat less
+readable interpolation form C<"\x{1}\x{14}\x{12c}\x{fa0}">.  This is useful
+for representing Unicode strings, and for comparing version "numbers"
+using the string comparison operators, C<cmp>, C<gt>, C<lt> etc.
+
+If there are more than two dots in the literal, the leading C<v> may be
+omitted.
+
+Such literals are accepted by both C<require> and C<use> for doing a version
+check.  The C<$^V> special variable also contains the running Perl
+interpreter's version in this form.  See L<perlvar/$^V>.
+
 =head2 Integer Arithmetic
 
 By default, Perl assumes that it must do most of its arithmetic in
@@ -1887,3 +1905,5 @@ limited-precision representations.
 The non-standard modules SSLeay::BN and Math::Pari provide
 equivalent functionality (and much more) with a substantial
 performance savings.
+
+=cut