commit fcfff55: [Minor] Use a scalar variable as a dir handle

Alexander Moisseev moiseev at mezonplus.ru
Thu Apr 6 21:14:03 UTC 2023


Author: Alexander Moisseev
Date: 2023-04-06 17:22:52 +0300
URL: https://github.com/rspamd/rspamd/commit/fcfff55f03afcf653eaabd2b38e5a6cfc6818d3a (refs/pull/4457/head)

[Minor] Use a scalar variable as a dir handle
instead of a bareword

---
 utils/rspamd_stats.pl | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/utils/rspamd_stats.pl b/utils/rspamd_stats.pl
index e90524d20..9c5f2acb0 100755
--- a/utils/rspamd_stats.pl
+++ b/utils/rspamd_stats.pl
@@ -678,20 +678,20 @@ sub JsonObjectElt() {
 
 sub GetLogfilesList {
     my ($dir) = @_;
-    opendir( DIR, $dir ) or die $!;
+    opendir( my $fh, $dir ) or die $!;
 
     my $pattern = join( '|', keys %decompressor );
     my $re      = qr/\.[0-9]+(?:\.(?:$pattern))?/;
 
     # Add unnumbered logs first
     my @logs =
-      grep { -f "$dir/$_" && !/$re/ } readdir(DIR);
+      grep { -f "$dir/$_" && !/$re/ } readdir($fh);
 
     # Add numbered logs
-    rewinddir(DIR);
-    push( @logs, ( sort numeric ( grep { -f "$dir/$_" && /$re/ } readdir(DIR) ) ) );
+    rewinddir($fh);
+    push( @logs, ( sort numeric ( grep { -f "$dir/$_" && /$re/ } readdir($fh) ) ) );
 
-    closedir(DIR);
+    closedir($fh);
 
     # Select required logs and revers their order
     @logs =


More information about the Commits mailing list