sbingner 25 лет назад
Родитель
Сommit
a07203f24e
1 измененных файлов с 7 добавлено и 17 удалено
  1. 7 17
      pisg.pl

+ 7 - 17
pisg.pl

@@ -365,29 +365,19 @@ sub init_debug
 
 sub parse_dir
 {
+    # Add trailing slash when it's not there..
+    $conf->{logdir} =~ s/([^\/])$/$1\//;
+
     print "Going into $conf->{logdir} and parsing all files there...\n\n";
     my @filesarray;
     opendir(LOGDIR, $conf->{logdir}) or die("Can't opendir $conf->{logdir}: $!");
-    unless (@filesarray = readdir(LOGDIR)) {
-        die("No files in $conf->{logdir}!");
-    }
+    @filesarray = grep { /^[^\.]/ && /^$conf->{prefix}/ && -f "$conf->{logdir}/$_" } readdir(LOGDIR) or die("No files in \"$conf->{logdir}\" matched prefix \"$conf->{prefix}\"");
     close(LOGDIR);
-
-    # Add trailing slash when it's not there..
-    if (substr($conf->{logdir}, -1) ne '/') {
-        $conf->{logdir} =~ s/(.*)/$1\//;
-    }
     
-    my $parsed = 0;
-    foreach my $file (grep /^$conf->{prefix}/, @filesarray) {
-        unless ($file eq "." or $file eq "..") {
-            $file = $conf->{logdir} . $file;
-            parse_file($file);
-            $parsed = 1;
-        }
+    foreach my $file (@filesarray) {
+        $file = $conf->{logdir} . $file;
+        parse_file($file);
     }
-
-    die "No files matched prefix $conf->{prefix} in directory $conf->{logdir}" unless ($parsed);
 }
 
 sub parse_file