[comp.lang.perl] namespace issues

tchrist@convex.COM (Tom Christiansen) (11/28/90)

I've been sitting here wondering why if readdir() is so
much like <handle>, in that it returns the next element 
in a scalar context and the whole shebang in an array one,
and it takes this special handle.

Because we have effectively separate namespaces for files
and directories, doing <dirhandle> doesn't make a bunch of 
sense.  Perl can't tell whether you want a file called 
"handle" or a directory called this, because both might
exist.  If, however, they shared a name space but had 
a bit attached to them internally telling which they
were opened as, then we could write things like this:

    opendir(DIR, ".") || die "SNAFU";
    $\ = "\n";
    while (<DIR>) {
	print;
	next if /^\./ || -d;
	unlink;
    }

My question is: does anyone (ab)use the fact that you can
have both a file and a directory whose handle is "HANDLE",
and thus whose script would break were this to change?

When Larry comes back out of the Book, maybe he can fill us 
in on why he didn't do it that way in the first place.

--tom