Move the pack warnings to their own file, as pointed
[p5sagit/p5-mst-13.2.git] / pod / perldata.pod
index 70ab161..b7c3b1c 100644 (file)
@@ -209,9 +209,9 @@ with a regular expression (as documented in L<perlre>).
        unless /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/;
 
 The length of an array is a scalar value.  You may find the length
-of array @days by evaluating C<$#days>, as in B<csh>.  Technically
-speaking, this isn't the length of the array; it's the subscript
-of the last element, since there is ordinarily a 0th element.
+of array @days by evaluating C<$#days>, as in B<csh>.  However, this
+isn't the length of the array; it's the subscript of the last element,
+which is a different value since there is ordinarily a 0th element.
 Assigning to C<$#days> actually changes the length of the array.
 Shortening an array this way destroys intervening values.  Lengthening
 an array that was previously shortened does not recover values
@@ -271,11 +271,18 @@ integer formats:
     12345
     12345.67
     .23E-10             # a very small number
-    4_294_967_296       # underline for legibility
+    3.14_15_92          # a very important number
+    4_294_967_296       # underscore for legibility
     0xff                # hex
+    0xdead_beef         # more hex   
     0377                # octal
     0b011011            # binary
 
+You are allowed to use underscores (underbars) in numeric literals
+between digits for legibility.  You could, for example, group binary
+digits by threes (as for a Unix-style mode argument such as 0b110_100_100)
+or by fours (to represent nibbles, as in 0b1010_0110) or in other groups.
+
 String literals are usually delimited by either single or double
 quotes.  They work much like quotes in the standard Unix shells:
 double-quoted string literals are subject to backslash and variable
@@ -413,20 +420,20 @@ string may be either an identifier (a word), or some quoted text.  If
 quoted, the type of quotes you use determines the treatment of the
 text, just as in regular quoting.  An unquoted identifier works like
 double quotes.  There must be no space between the C<< << >> and
-the identifier.  (If you put a space it will be treated as a null
-identifier, which is valid, and matches the first empty line.)  The
-terminating string must appear by itself (unquoted and with no
-surrounding whitespace) on the terminating line.
+the identifier, unless the identifier is quoted.  (If you put a space it
+will be treated as a null identifier, which is valid, and matches the first
+empty line.)  The terminating string must appear by itself (unquoted and
+with no surrounding whitespace) on the terminating line.
 
        print <<EOF;
     The price is $Price.
     EOF
 
-       print <<"EOF";  # same as above
+       print << "EOF"; # same as above
     The price is $Price.
     EOF
 
-       print <<`EOC`;  # execute commands
+       print << `EOC`; # execute commands
     echo hi there
     echo lo there
     EOC
@@ -437,7 +444,7 @@ surrounding whitespace) on the terminating line.
     I said bar.
     bar
 
-       myfunc(<<"THIS", 23, <<'THAT');
+       myfunc(<< "THIS", 23, <<'THAT');
     Here's a line
     or two.
     THIS
@@ -462,6 +469,39 @@ from each line manually:
        down from the door where it began.
     FINIS
 
+If you use a here-doc within a delimited construct, such as in C<s///eg>,
+the quoted material must come on the lines following the final delimiter.
+So instead of
+
+    s/this/<<E . 'that'
+    the other
+    E
+     . 'more '/eg;
+
+you have to write
+
+    s/this/<<E . 'that' 
+     . 'more '/eg; 
+    the other 
+    E 
+
+If the terminating identifier is on the last line of the program, you
+must be sure there is a newline after it; otherwise, Perl will give the
+warning B<Can't find string terminator "END" anywhere before EOF...>.
+
+Additionally, the quoting rules for the identifier are not related to
+Perl's quoting rules -- C<q()>, C<qq()>, and the like are not supported
+in place of C<''> and C<"">, and the only interpolation is for backslashing
+the quoting character:
+
+    print << "abc\"def";
+    testing...
+    abc"def
+
+Finally, quoted strings cannot span multiple lines.  The general rule is
+that the identifier must be a string literal.  Stick with that, and you
+should be safe.
+
 =head2 List value constructors
 
 List values are denoted by separating individual values by commas
@@ -524,6 +564,15 @@ has no effect.  Thus ((),(),()) is equivalent to ().  Similarly,
 interpolating an array with no elements is the same as if no
 array had been interpolated at that point.
 
+This interpolation combines with the facts that the opening
+and closing parentheses are optional (except necessary for
+precedence) and lists may end with an optional comma to mean that
+multiple commas within lists are legal syntax. The list C<1,,3> is a
+concatenation of two lists, C<1,> and C<3>, the first of which ends
+with that optional comma.  C<1,,3> is C<(1,),(3)> is C<1,3> (And
+similarly for C<1,,,3> is C<(1,),(,),3> is C<1,3> and so on.)  Not that
+we'd advise you to use this obfuscation.
+
 A list value may also be subscripted like a normal array.  You must
 put the list in parentheses to avoid ambiguity.  For example: