sub ScanDirectory{ my ($startdir) = @_; chdir("$stardir\\") or die "Unable to enter dir $startdir:$!\n"; opendir(DIR, "$startdir") or die "Unable to open $workdir:$!\n"; my @names = readdir(DIR) or die "Unable to read $workdir:$!\n"; closedir(DIR); foreach my $name (@names) { next if ($name eq "."); next if ($name eq ".."); if (-d $name) # is this a directory? { print "DIRECTORY $currentDir \n"; } else { print "FILE $currentFile"; # it always passes through this condition. } }