Solved

recursive readdir in win32

Posted on 1998-12-14
1
910 Views
Last Modified: 2012-05-04
I need to perform an operation on a directory and its subdirectories in Win32. I thought it would be easy but am having some difficulties. Please provide some generic code. Thanks.
0
Comment
Question by:Pakfan
1 Comment
 
LVL 5

Accepted Solution

by:
b2pi earned 90 total points
ID: 1206937
my($root) = "C:\\users";
DoDir($root);

sub DoDir {
   my($dir) = shift;
   my($file);
   opendir(DIR, $dir) || die "Unable to open $dir :$!";
   my(@files) = grep {!/^\.\.?$/ } readdir(DIR);
   closedir(DIR);
   foreach (@files) {
      if (-d ($file = "$dir\\$_")) {
           print "Found a directory: $file\n";
            DoDir($file);
      } else {
            print "File $file\n";
      }
   }
}

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
HTTP Error 502.2 - Bad Gateway 3 205
remove duplicates from the csv file 13 102
Removing file extension within a file. 4 90
ppm conversion to curl on a module install 8 80
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now