SM_PATH fix
[squirrelmail.git] / config / ri_once.pl
index 3c77f2ae89cb4241fef705a039fc9e20d78d2acb..9593a156f8a6f85624e5e0319f4528277a867ead 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # ri_once.pl
 # Wouter Teepe (wouter@teepe.com)
 #
@@ -215,15 +215,28 @@ sub dofile {
 
 # process a directory recursively
 sub dodir {
+    my $dirname;
+    my $file;
+    my $full;
+    my @files;
+    my $i;
     $dirname = $_[0];
     $dirname =~ s/\/$//;
     opendir(DIR, $dirname) or die "can't opendir $dirname: $!";
+    $i = 0;
     while (defined($file = readdir(DIR))) {
+        @files[$i++] = $file;
+    }
+    $i = 0;
+    while (defined($file = @files[$i++])) {
        next if $file =~ /^\.\.?$/;
        $full = $dirname.'/'.$file;
+#        print "found: $full\n";
        if (-d $full) {
+#            print "doing dir: $full\n";
            &dodir($full);
        } else { if ($file =~ /.*\.php$/) {
+#            print "doing file: $full\n";
            &dofile($full);
        }}
     }