develooper Front page | perl.perl5.porters | Postings from March 2001

[PATCH] perldata.pod here-doc docs

From:
Jeff Pinyan
Date:
March 8, 2001 10:19
Subject:
[PATCH] perldata.pod here-doc docs
Message ID:
Pine.GSO.4.21.0103081317530.20957-100000@crusoe.crusoe.net
Patch after sig.

-- 
Jeff "japhy" Pinyan      japhy@pobox.com      http://www.pobox.com/~japhy/
Are you a Monk?  http://www.perlmonks.com/     http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc.     http://www.riskmetrics.com/


--- perldata.pod.old	Thu Mar  8 13:11:17 2001
+++ perldata.pod	Thu Mar  8 13:26:50 2001
@@ -413,20 +413,20 @@
 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 +437,7 @@
     I said bar.
     bar
 
-	myfunc(<<"THIS", 23, <<'THAT');
+	myfunc(<< "THIS", 23, <<'THAT');
     Here's a line
     or two.
     THIS
@@ -477,6 +477,23 @@
      . '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
 




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About