In FindExt, use File::Find instead of shelling out to a dir command.
authorNicholas Clark <nick@ccl4.org>
Tue, 18 Jun 2013 09:26:50 +0000 (11:26 +0200)
committerNicholas Clark <nick@ccl4.org>
Tue, 18 Jun 2013 18:49:13 +0000 (20:49 +0200)
The FindExt code is tested on *nix, and at least some systems have a dir
executable, which generates warnings to stderr when invoked with parameters
intended for the Win32 dir command.

File::Find is portable, and avoids starting a new process.

win32/FindExt.pm

index c7e52ae..2e4d6c1 100644 (file)
@@ -54,13 +54,15 @@ sub set_static_extensions {
     # For other nested extensions, this is handled automatically by
     # the appropriate Makefile.PL.
     if ($ext{Encode} && $ext{Encode} eq 'static') {
-       foreach my $file (`dir /s /b ..\\cpan\\Encode\\Makefile.PL`) {
-           if ($file =~ /\b(Encode\\.+)\\Makefile\.PL/) {
-               (my $xxx = $1) =~ s|\\|/|g;
-               $static{$xxx} = 1;
-               $ext{$xxx} = 'static';
-           }
-       }
+        require File::Find;
+        File::Find::find({
+                          no_chdir => 1,
+                          wanted => sub {
+                              return unless m!\b(Encode/.+)/Makefile\.PL!;
+                              $static{$1} = 1;
+                              $ext{$1} = 'static';
+                          },
+                         }, "../cpan/Encode");
     }
 }