HENRY,MARK (HP-Roseville,ex1) wrote:
> Hi All,
> 
> I'm experiencing some odd results using the x file tests on files and
> directories.
> 
> When I run the following:
> 
> opendir(CURDIR, "c:\\") or die "cant open directory: $!\n";
>       foreach $direntry (readdir CURDIR) {
>               if (-f $direntry) { print "$direntry is a file..\n"; }
>               elsif (-d $direntry) { print "$direntry is a directory..\n";
> }
>       }
> 
> ..out of the approx 55 directories and 96 files in my root dir, I
> only get one single print statement to fire on one very uninteresting
> text file. 
> 
> Granted perl may not recognize what exactly the different binary file
> are, but shouldn't it report that they're at least files - an it
> recognizes directories at all.
> 
> I'm using activestate build 633..
> 
> Cheers,
> 
> Mark

That is because you are not where you think you are. Unless you do a chdir
then you will get the dir or file as relates to the readdir. When you do the
test -f or -d , looks at the file or directory but in relationship to the
current working directory and I would believe it is not C:/. What I did was:

        my $MyItem = $MyLoc . $direntry;
     where $MyLoc was set to c:/ and then did the tests against $MyItem, but
displayed what was in $direntry.

Wags ;)


**********************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
****************************************************************


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to