On Saturday, November 2, 2002, at 10:07 PM, John Delacour wrote:
If I do this...That's because it's testing the names in $_ relative to your *current* directory, not relative to $ENV{HOME}. Try this instead:
#!/usr/bin/perl
$dir = "$ENV{HOME}/";
opendir DIR, $dir ;
for (readdir DIR) {
-d and print "$dir$_$/"
}
....I aim to get all the files in my home directory that are directories, but the result is a list of only a few of the existing directories:
/Users/jd/.
/Users/jd/..
/Users/jd/dev
/Users/jd/Library
#!/usr/bin/perl
$dir = "$ENV{HOME}/";
opendir DIR, $dir ;
for (readdir DIR) {
-d "$dir$_" and print "$dir$_$/"
}
How do I get a list of all directories in a directory and, more to the point, what is the best way to get a complete tree starting from a certain directory?
File::Find, as others have mentioned.
-Ken