Solved

recursive readdir in win32

Posted on 1998-12-14
1
902 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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
MySQL Web Database 5 105
Validating the data using Oracle DBD module. 5 62
transpose into pipe delemited 8 65
Perl Frameworks 1 51
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…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

771 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

13 Experts available now in Live!

Get 1:1 Help Now