From a5f581c55b0cc45f89da55441d6992f1dfc204f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20=C3=89LIE?= Date: Sun, 8 Sep 2024 08:58:49 +0200 Subject: [PATCH] Use my instead of local for local variables To comply with the perlcritic Variables::ProhibitLocalVars policy. --- contrib/archivegz.in | 23 ++++++++++++----------- contrib/makeexpctl.in | 2 +- innfeed/testListener.pl | 14 ++++++++------ storage/ovsqlite/ovsqlite-util.in | 2 +- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/contrib/archivegz.in b/contrib/archivegz.in index f7e4fc24e..8c091e9e1 100644 --- a/contrib/archivegz.in +++ b/contrib/archivegz.in @@ -60,7 +60,7 @@ if ($timeout < 1) { $timeout = 1; } # -------------------------------------------------------------------- sub regexp_escape { - local ($data) = @_; + my ($data) = @_; $data =~ s+\\+\\\\+gi; # replace \ with \\ $data =~ s+\/+\\\/+gi; # replace / with \/ @@ -71,8 +71,8 @@ sub regexp_escape { } sub fhbits { - local (@fhlist) = split(' ', $_[0]); - local ($bits); + my (@fhlist) = split(' ', $_[0]); + my ($bits); for (@fhlist) { vec($bits, fileno($_), 1) = 1; } @@ -81,18 +81,19 @@ sub fhbits { sub timed_getline { my ($fileh, $timeout) = @_; - local (*FILEH) = *$fileh{FILEHANDLE}; - local ($rin, $win, $ein); - local ($rout, $wout, $eout); + local (*FILEH) = *$fileh{FILEHANDLE}; ## no critic (ProhibitLocalVars) + + my ($rin, $win, $ein); + my ($rout, $wout, $eout); $rin = $win = $ein = ''; $rin = fhbits('FILEH'); $ein = $rin | $win; - local ($nfound); - local ($offset) = 0; - local ($accum) = ''; - local ($done) = 0; - local ($result); + my ($nfound); + my ($offset) = 0; + my ($accum) = ''; + my ($done) = 0; + my ($result); $nfound = select($rout = $rin, $wout = $win, $eout = $ein, $timeout); diff --git a/contrib/makeexpctl.in b/contrib/makeexpctl.in index ab9325c02..e8da0e8e5 100644 --- a/contrib/makeexpctl.in +++ b/contrib/makeexpctl.in @@ -79,7 +79,7 @@ close(OUTFILE); exit(1); sub printline { - local ($grpstr, $mflag, $len) = @_; + my ($grpstr, $mflag, $len) = @_; print OUTFILE $grpstr, ":", $mflag, ":", $len * $scale, ":", $len * $scale, ":", $len * $scale, "\n"; } diff --git a/innfeed/testListener.pl b/innfeed/testListener.pl index 5c9d83add..31fbe18dc 100755 --- a/innfeed/testListener.pl +++ b/innfeed/testListener.pl @@ -79,12 +79,14 @@ sub sigHup { $letstr = "abcdefghijklmnopqrstuvwxyz"; sub createArticle { - local ($counter) = @_; - local ($filename, $msgid, $i); - local ($time) = $^T; - local ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) - = gmtime($time); - local ($index) = $counter; + my ($counter) = @_; + my ($filename, $msgid, $i); + my ($time) = $^T; + my ( + $sec, $min, $hour, $mday, $mon, $year, $wday_unused, $yday_unused, + $isdst_unused, + ) = gmtime($time); + my ($index) = $counter; if ($opt_a && ((int(rand(4)) % 2) == 0)) { $index = int($index / 2); diff --git a/storage/ovsqlite/ovsqlite-util.in b/storage/ovsqlite/ovsqlite-util.in index 1bfe49ebf..cb0503fc9 100644 --- a/storage/ovsqlite/ovsqlite-util.in +++ b/storage/ovsqlite/ovsqlite-util.in @@ -223,7 +223,7 @@ select groupid from groupinfo # The AutoCommit attribute needs being true so as not to start a transaction. sub pragma_foreign_keys { my $onoff = shift; - local $dbh->{AutoCommit} = 1; + local $dbh->{AutoCommit} = 1; ## no critic (ProhibitLocalVars) $dbh->do("pragma foreign_keys = $onoff;"); }