From: Paul Wise Date: Wed, 21 Jun 2023 08:50:27 +0000 (+0200) Subject: checksrc: modernise perl file open X-Git-Tag: curl-8_2_0~55 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7f669aa0f1d40ef5d64543981f22bdc5af1272f5;p=thirdparty%2Fcurl.git checksrc: modernise perl file open Use regular variables and separate file open modes from filenames. Suggested by perlcritic Copied from https://github.com/curl/trurl/commit/f2784a9240f47ee28a845 Closes #11358 --- diff --git a/scripts/checksrc.pl b/scripts/checksrc.pl index 5c279db903..c1ee27966e 100755 --- a/scripts/checksrc.pl +++ b/scripts/checksrc.pl @@ -99,13 +99,13 @@ my %warnings = ( ); sub readskiplist { - open(W, "<$dir/checksrc.skip") or return; - my @all=; + open(my $W, '<', "$dir/checksrc.skip") or return; + my @all=<$W>; for(@all) { $windows_os ? $_ =~ s/\r?\n$// : chomp; $skiplist{$_}=1; } - close(W); + close($W); } # Reads the .checksrc in $dir for any extended warnings to enable locally. @@ -381,7 +381,7 @@ sub scanfile { my $l = ""; my $prep = 0; my $prevp = 0; - open(R, "<$file") || die "failed to open $file"; + open(my $R, '<', $file) || die "failed to open $file"; my $incomment=0; my @copyright=(); @@ -389,7 +389,7 @@ sub scanfile { checksrc_clear(); # for file based ignores accept_violations(); - while() { + while(<$R>) { $windows_os ? $_ =~ s/\r?\n$// : chomp; my $l = $_; my $ol = $l; # keep the unmodified line for error reporting @@ -939,7 +939,7 @@ sub scanfile { checksrc_endoffile($file); - close(R); + close($R); }