Hi,

The following code doesn't recognize dirs. As I list the dir into the XML, it 
shows dirs as ordinary files.

Like the -d would not work. If I add an extra branch to recognize files with 
-f, it doesn't print either files at all nor dirs.

sub Traverse
{
                opendir(DIR, $dir) or die "Cannot open directory $dir: $!\n";
                my @files = readdir(DIR);
                closedir(DIR);
                foreach my $file (@files) {
                    # generate XML here

                               next if (($file eq '.') || ($file eq '..'));

                               print $file;
                               if((-d $file) and ($file !~ /^\.\.?$/) and 
($file ne ".") and ($file ne "..")) {
                                               # make dir branch
                                               $writer->startTag("Folder", 
"Name" => $file);
                                               Traverse($file);
                                               $writer->endTag("Folder");
                               } else {
                                               $writer->emptyTag("Object", 
"Name" => $file);
                                               # make file branch
                               }
                }
}


Tamas

Reply via email to