summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/User/pwent.pm2
-rw-r--r--pod/perldata.pod22
2 files changed, 23 insertions, 1 deletions
diff --git a/lib/User/pwent.pm b/lib/User/pwent.pm
index f41aa2ab5a..8c059265c3 100644
--- a/lib/User/pwent.pm
+++ b/lib/User/pwent.pm
@@ -250,7 +250,7 @@ You may ask whether one of these was implemented on the system Perl
was built on by asking the importable C<pw_has> function about them.
This function returns true if all parameters are supported fields
on the build platform, false if one or more were not, and raises
-and exception if you asked about a field that Perl never knows how
+an exception if you asked about a field that Perl never knows how
to provide. Parameters may be in a space-separated string, or as
separate arguments. If you pass no parameters, the function returns
the list of C<struct pwd> fields supported by your build platform's
diff --git a/pod/perldata.pod b/pod/perldata.pod
index 3e10e6f3d4..ac444fa17c 100644
--- a/pod/perldata.pod
+++ b/pod/perldata.pod
@@ -750,6 +750,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