There are a number of ways to do this, although I cannot say
definitely if this will work with a space in a directory. However
it should, theoretically still work by doing any of the following:
#!/usr/bin/perl -w
use strict;
my @result = map { glob($_) } "*";
foreach (@result)
{
if (-d "$_")
{
print "$_ is a directory\n";
}
}
This is directly from the camel book and will return a listing
of everything in the current directory. See the camel book for
more details on glob.
You can also use opendir and readdir to get a handle,
open the directory, read the directory, test if any files in
directory are directories. You might want to take the advice
from the camel book on this and use grep to avoid the "." and
".." directories, but it sounds like you are on a non-*nix system
so you may not need to worry about it.
The other way, is to use the File::Find which is well documented
both here and at CPAN.
Hope that helps. Nice to know you have so many choices, huh? Ain't
Perl great!
I admit it, I am Paco. |