Hello,

Is there anyway to grep on a readdir handle and only get the directories,
not any files?

eg.
open (SOMEDIRHANDLE, "$pathToDirectory") or die ("Problems opening
$pathToDirectory. $!");
my @directories = grep /-d/, readdir SOMEDIRHANDLE;
closedir SOMEDIRHANDLE;

That -d does NOT work, I get the following error:
Can't declare pattern match at the file and line number of the above.

I could grab all data, and iterate through it with a -d in a for loop, eg.
my @allstuff = grep !/^\./, readdir SOMEDIRHANDLE;
foreach (@allstuff) {
   if (-d "$pathToDirectory/$_") {
      push @directories, $_;
  }
}

But that just seemed inefficient? Maybe I am wrong.


Thanks,

Scott Purcell

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

Reply via email to