docfix from Peter Scott <Peter@PSDT.com>.
[p5sagit/p5-mst-13.2.git] / pod / perldata.pod
index 6ffd38c..a2bb840 100644 (file)
@@ -275,7 +275,6 @@ integer formats:
     0xff                # hex
     0377                # octal
     0b011011            # binary
-    v102.111.111        # string (made of characters "f", "o", "o")
 
 String literals are usually delimited by either single or double
 quotes.  They work much like quotes in the standard Unix shells:
@@ -304,7 +303,8 @@ price is $Z<>100."
     print "The price is $Price.\n";    # interpreted
 
 As in some shells, you can enclose the variable name in braces to
-disambiguate it from following alphanumerics.  You must also do
+disambiguate it from following alphanumerics (and underscores).
+You must also do
 this when interpolating a variable into a string to separate the
 variable name from a following double-colon or an apostrophe, since
 these would be otherwise treated as a package separator:
@@ -332,7 +332,13 @@ 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 two or more dots in the literal, the leading C<v> may be
-omitted.  Such literals are accepted by both C<require> and C<use> for
+omitted.
+
+    print v9786;              # prints UTF-8 encoded SMILEY, "\x{263a}"
+    print v102.111.111;       # prints "foo"
+    print 102.111.111;        # same
+
+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>.
 
@@ -745,6 +751,28 @@ C<*HANDLE{IO}> only works if HANDLE has already been used as a handle.
 In other words, C<*FH> must be used to create new symbol table entries;
 C<*foo{THING}> cannot.  When in doubt, use C<*FH>.
 
+All functions that are capable of creating filehandles (open(),
+opendir(), pipe(), socketpair(), sysopen(), socket(), and accept())
+automatically create an anonymous filehandle if the handle passed to
+them is an uninitialized scalar variable. This allows the constructs
+such as C<open(my $fh, ...)> and C<open(local $fh,...)> to be used to
+create filehandles that will conveniently be closed automatically when
+the scope ends, provided there are no other references to them. This
+largely eliminates the need for typeglobs when opening filehandles
+that must be passed around, as in the following example:
+
+    sub myopen {
+        open my $fh, "@_"
+            or die "Can't open '@_': $!";
+       return $fh;
+    }
+
+    {
+        my $f = myopen("</etc/motd");
+       print <$f>;
+       # $f implicitly closed here
+    }
+
 Another way to create anonymous filehandles is with the Symbol
 module or with the IO::Handle module and its ilk.  These modules
 have the advantage of not hiding different types of the same name