sub PopulateTree { my $path = shift; my $hashref = shift; wlog("Looking in $path..."); $pathcount++; #Added to get rid of empty dirs my $fixedpath = TrimPath($path); unless (-d $fixedpath) { mkdir $fixedpath, 0777; push @badpaths, $path; wlog( "Bad path found. Marked for deletion." ); } my $dir = new IO::Dir; my @dirContents; unless ($dir->open($path)) { warn("Couldn't open directory $path: $!\n"); return undef; }; unless (@dirContents = $dir->read()) { warn("Couldn't read directory $path: $!\n"); return undef; }; # now look at each item and decide what to do with it if (($#dirContents == 1) && ($path ne $inDir)) { push @badpaths, $path; push @badpaths, $fixedpath; wlog( "Empty path found. Marked for deletion." ); } ITEM: foreach my $item (@dirContents) { if (($item eq '.') || ($item eq '..')) { next ITEM; }; if (-d $path.$item) { # it's a directory, create an item entry for it $hashref->{$item} = { Type => 'Dir', Contents => {} }; # get its contents unless (PopulateTree($path.$item.'/', $hashref->{$item}->{Contents})) { warn("PopulateTree failed"); return undef; }; } elsif (-f _) { # create an item entry for it $hashref->{$item} = { Type => 'File',}; } else { wlog("$path$item is not a directory or file."); }; }; return 1; }; #### Looking in C:/Documents and Settings/jmaggard/Desktop/New Folder/... C:/Documents and Settings/jmaggard/Desktop/New Folder/ Pg. 1_ 3 Col. x 18? is not a directory or file. C:/Documents and Settings/jmaggard/Desktop/New Folder/ Pg. 2_ 3 Col. x 14? is not a directory or file. C:/Documents and Settings/jmaggard/Desktop/New Folder/ Pg. 3_ 2 Col. x 13? & 18? is not a directory or file. C:/Documents and Settings/jmaggard/Desktop/New Folder/ Pg. 4_ 2 x 13? & 3 x 14? is not a directory or file. #### 20 50 67 2E 20 34 5F 20 32 20 78 20 31 33 3F 20 26 20 33 20 78 20 31 34 3F