From: Nathan Torkington Date: Sat, 12 Apr 2003 12:40:45 +0000 (+0000) Subject: Document and test autovivified dirhandles. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a28cd5c9762e7188f862844ca6b6674b912f33f8;p=p5sagit%2Fp5-mst-13.2.git Document and test autovivified dirhandles. Subject: [perl #21952] [patch] t/op/readdir.t and perlfunc.pod From: Nathan Torkington (via RT) Message-Id: p4raw-id: //depot/perl@19207 --- diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index efe01df..36999b9 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 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.) -If FILEHANDLE is an undefined lexical (C) 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 should I 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 should I 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 for some details about mixing reading and writing. Opens a directory named EXPR for processing by C, C, C, C, and C. 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 83451d3..ee64122 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"; }