diff options
author | Nathan Torkington <gnat@frii.com> | 2003-04-12 12:40:45 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2003-04-14 19:34:42 +0000 |
commit | a28cd5c9762e7188f862844ca6b6674b912f33f8 (patch) | |
tree | 440cbf90415c72a74fa2613ca53024c9d0438983 | |
parent | 244d9cb7d1d2e3a6aaa13f677e17b42673b10de9 (diff) | |
download | perl-a28cd5c9762e7188f862844ca6b6674b912f33f8.tar.gz |
Document and test autovivified dirhandles.
Subject: [perl #21952] [patch] t/op/readdir.t and perlfunc.pod
From: Nathan Torkington (via RT) <perlbug-followup@perl.org>
Message-Id: <rt-21952-55079.8.08945458828887@bugs6.perl.org>
p4raw-id: //depot/perl@19207
-rw-r--r-- | pod/perlfunc.pod | 17 | ||||
-rwxr-xr-x | t/op/readdir.t | 11 |
2 files changed, 19 insertions, 9 deletions
diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index efe01dfa75..36999b923f 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -790,9 +790,6 @@ filehandle, usually the real filehandle name. Closes a directory opened by C<opendir> and returns the success of that system call. -DIRHANDLE may be an expression whose value can be used as an indirect -dirhandle, usually the real dirhandle name. - =item connect SOCKET,NAME Attempts to connect to a remote socket, just as the connect system call @@ -2757,11 +2754,11 @@ FILEHANDLE. (The following is a comprehensive reference to open(): for a gentler introduction you may consider L<perlopentut>.) -If FILEHANDLE is an undefined lexical (C<my>) variable the variable is -assigned a reference to a new anonymous filehandle, otherwise if -FILEHANDLE is an expression, its value is used as the name of the real -filehandle wanted. (This is considered a symbolic reference, so C<use -strict 'refs'> should I<not> be in effect.) +If FILEHANDLE is an undefined scalar variable (or array or hash element) +the variable is assigned a reference to a new anonymous filehandle, +otherwise if FILEHANDLE is an expression, its value is used as the name of +the real filehandle wanted. (This is considered a symbolic reference, so +C<use strict 'refs'> should I<not> be in effect.) If EXPR is omitted, the scalar variable of the same name as the FILEHANDLE contains the filename. (Note that lexical variables--those @@ -3089,6 +3086,10 @@ See L</seek> for some details about mixing reading and writing. Opens a directory named EXPR for processing by C<readdir>, C<telldir>, C<seekdir>, C<rewinddir>, and C<closedir>. Returns true if successful. +DIRHANDLE may be an expression whose value can be used as an indirect +dirhandle, usually the real dirhandle name. If DIRHANDLE is an undefined +scalar variable (or array or hash element), the variable is assigned a +reference to a new anonymous dirhandle. DIRHANDLEs have their own namespace separate from FILEHANDLEs. =item ord EXPR diff --git a/t/op/readdir.t b/t/op/readdir.t index 83451d3d68..ee641227b7 100755 --- a/t/op/readdir.t +++ b/t/op/readdir.t @@ -8,7 +8,7 @@ BEGIN { eval 'opendir(NOSUCH, "no/such/directory");'; if ($@) { print "1..0\n"; exit; } -print "1..3\n"; +print "1..11\n"; for $i (1..2000) { local *OP; @@ -44,3 +44,12 @@ while (@R && @G && $G[0] eq ($^O eq 'MacOS' ? ':op:' : 'op/').$R[0]) { shift(@G); } if (@R == 0 && @G == 0) { print "ok 3\n"; } else { print "not ok 3\n"; } + +if (opendir($fh, "op")) { print "ok 4\n"; } else { print "not ok 4\n"; } +if (ref($fh) eq 'GLOB') { print "ok 5\n"; } else { print "not ok 5\n"; } +if (opendir($fh[0], "op")) { print "ok 6\n"; } else { print "not ok 6\n"; } +if (ref($fh[0]) eq 'GLOB') { print "ok 7\n"; } else { print "not ok 7\n"; } +if (opendir($fh{abc}, "op")) { print "ok 8\n"; } else { print "not ok 8\n"; } +if (ref($fh{abc}) eq 'GLOB') { print "ok 9\n"; } else { print "not ok 9\n"; } +if ("$fh" ne "$fh[0]") { print "ok 10\n"; } else { print "not ok 10\n"; } +if ("$fh" ne "$fh{abc}") { print "ok 11\n"; } else { print "not ok 11\n"; } |