B
Bob Gervais
Hi,
I am writing a very simple script that should return all
subdirectories on a given path (non recursively, so just first level).
This is the sub that I have for doing this but it gives very strange
results:
sub FindFiles
{
my ($dir) = @_ ;
my @files ;
opendir THISDIR, $dir or die "Error, cannot do opendir on $dir $!"
;
my @allfiles = readdir THISDIR ;
closedir THISDIR ;
foreach my $file (@allfiles)
{
#if (-d $file)
# {
# print $file."\n";
# };
push @files, $file if (-d $file) ;
}
return (@files)
}
When I run this on the same path as the script is located ('.') it
gives me the correct results.
If I give a path along of where to check, it gives me a few of the
subdirs (for example on the C: drive it would give me the TEMP, the
WINDOWS and the RECYCLER directory, but not the PROGRAM FILES or some
other dirs I have.
I am using Perl 5.8 on a Windows XP machine.
Can anyone shed some light on this strange problem?
Thanx,
Bob
I am writing a very simple script that should return all
subdirectories on a given path (non recursively, so just first level).
This is the sub that I have for doing this but it gives very strange
results:
sub FindFiles
{
my ($dir) = @_ ;
my @files ;
opendir THISDIR, $dir or die "Error, cannot do opendir on $dir $!"
;
my @allfiles = readdir THISDIR ;
closedir THISDIR ;
foreach my $file (@allfiles)
{
#if (-d $file)
# {
# print $file."\n";
# };
push @files, $file if (-d $file) ;
}
return (@files)
}
When I run this on the same path as the script is located ('.') it
gives me the correct results.
If I give a path along of where to check, it gives me a few of the
subdirs (for example on the C: drive it would give me the TEMP, the
WINDOWS and the RECYCLER directory, but not the PROGRAM FILES or some
other dirs I have.
I am using Perl 5.8 on a Windows XP machine.
Can anyone shed some light on this strange problem?
Thanx,
Bob