From:                   Caroline Warnock <[EMAIL PROTECTED]>

> I'm trying to use the following, in order to be able to print the
> names of sub-directories within a directory:
> 
> 1     $folder = "/home/cwarnock/public_html/staged/DEVELOPMENT/"; 
> 2
> 3     opendir(DEV, $folder);
> 4
> 5     @all_files = readdir(DEV);
> 6
> 7     foreach $Name (@all_files) {
> 8             print  $Name;
> 9             if(-d $Name){
> 10                    print "$Name\n"; 
> 11                    }
> 
> I know that the directory has at least 4 sub-directories.
> 
> The 'print $Name;' on line 8, correctly prints all the sub-directory
> and file names as well as '.' and '..'.
> However, the 'print "$Name\n";' on line 10 (after the if statement)
> only prints '.' and '..'. None of the other 4 directories are
> printed.

The readdir only returns the NAME of the file/directory, not the 
whole path. So you have to use

        if (-d "$folder/$Name") ...

Jenda


=========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==========
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain.
I can't find it.
                                        --- me

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

Reply via email to