summaryrefslogtreecommitdiff
path: root/dselect
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2013-01-11 19:57:35 +0100
committerGuillem Jover <guillem@debian.org>2013-05-08 04:58:08 +0200
commit17ae5451263121467ed9b0a45dfddc1c4336a930 (patch)
tree8d9e48f24cb18732378878949f4bb359ff07ed14 /dselect
parente1fba416fa57c7cb18e52cc994f6d3608fbfe7e7 (diff)
downloaddpkg-17ae5451263121467ed9b0a45dfddc1c4336a930.tar.gz
perl: Use my-style lexical loop iterator variables
The variables used on a foreach loop are local to that block, so if we wanted to use it after the loop is finished the last value would be gone. Fixes Variables::RequireLexicalLoopIterators. Warned-by: perlcritic
Diffstat (limited to 'dselect')
-rwxr-xr-xdselect/methods/ftp/install33
-rwxr-xr-xdselect/methods/ftp/setup7
-rwxr-xr-xdselect/methods/ftp/update7
-rwxr-xr-xdselect/mkcurkeys.pl2
4 files changed, 21 insertions, 28 deletions
diff --git a/dselect/methods/ftp/install b/dselect/methods/ftp/install
index d7e13ce0f..576aace49 100755
--- a/dselect/methods/ftp/install
+++ b/dselect/methods/ftp/install
@@ -155,7 +155,7 @@ sub procpkgfile {
my $fn = shift;
my $site = shift;
my $dist = shift;
- my(@files,@sizes,@md5sums,$pkg,$ver,$fl,$nfs,$fld);
+ my (@files, @sizes, @md5sums, $pkg, $ver, $nfs, $fld);
my(%flds);
open(my $pkgfile_fh, '<', $fn) or die "Could not open package file $fn";
while (%flds = getblk($pkgfile_fh), %flds) {
@@ -173,7 +173,7 @@ sub procpkgfile {
print "Different number of filenames, sizes and md5sums for $flds{'package'}\n";
} else {
my $i = 0;
- foreach $fl (@files) {
+ foreach my $fl (@files) {
$pkgfiles{$fl} = [ $md5sums[$i], $sizes[$i], $site, $dist ];
$i++;
}
@@ -183,11 +183,11 @@ sub procpkgfile {
}
print "\nProcessing Package files...\n";
-my ($dist,$site,$fn,$i,$j);
+my ($fn, $i, $j);
$i = 0;
-foreach $site (@{$config{site}}) {
+foreach my $site (@{$config{site}}) {
$j = 0;
- foreach $dist (@{$site->[2]}) {
+ foreach my $dist (@{$site->[2]}) {
$fn = $dist;
$fn =~ tr#/#_#;
$fn = "Packages.$site->[0].$fn";
@@ -217,11 +217,11 @@ sub md5sum($) {
# query user for each paritial file
print "\nConstructing list of files to get...\n";
my %downloads;
-my ($pkg, $dir, @info, @files, $csize, $size);
+my ($dir, @info, @files, $csize, $size);
my $totsize = 0;
-foreach $pkg (keys(%pkgs)) {
+foreach my $pkg (keys(%pkgs)) {
@files = @{$pkgs{$pkg}[1]};
- foreach $fn (@files) {
+ foreach my $fn (@files) {
#Look for a partial file
if (-f "$dldir/$fn.partial") {
rename "$dldir/$fn.partial", "$dldir/$fn";
@@ -288,9 +288,8 @@ if($totsize == 0) {
yesno('n', 'Do you want to select the files to get')) {
$totsize = 0;
my @files = sort(keys(%downloads));
- my $fn;
my $def = 'y';
- foreach $fn (@files) {
+ foreach my $fn (@files) {
my @info = @{$pkgfiles{$fn}};
my $csize = int($info[1] / 1024) + 1;
my $rsize = int(($info[1] - $downloads{$fn}) / 1024) + 1;
@@ -315,9 +314,9 @@ if($totsize == 0) {
sub download() {
my $i = 0;
- my ($site, $ftp);
+ my $ftp;
- foreach $site (@{$config{site}}) {
+ foreach my $site (@{$config{site}}) {
my @getfiles = grep { $pkgfiles{$_}[2] == $i } keys %downloads;
my @pre_dist = (); # Directory to add before $fn
@@ -350,8 +349,8 @@ sub download() {
$::ftp = $ftp;
local $SIG{INT} = sub { die "Interrupted !\n"; };
- my ($fn,$rsize,$res,$pre);
- foreach $fn (@getfiles) {
+ my ($rsize, $res, $pre);
+ foreach my $fn (@getfiles) {
$pre = $pre_dist[$pkgfiles{$fn}[3]] || '';
if ($downloads{$fn}) {
$rsize = ${pkgfiles{$fn}}[1] - $downloads{$fn};
@@ -420,8 +419,7 @@ if($totsize != 0) {
if (yesno('y', "\nDo you want to retry downloading at once")) {
# get the first $fn that foreach would give:
# this is the one that got interrupted.
- my $ffn;
- MY_ITER: foreach $ffn (keys(%downloads)) {
+ MY_ITER: foreach my $ffn (keys(%downloads)) {
$fn = $ffn;
last MY_ITER;
}
@@ -505,8 +503,7 @@ sub prcdeb($$) {
print "old version\n";
unlink $fn;
} else { # else $ver is gt current version
- my ($c);
- foreach $c (@{$files{$pkg . $vers{$pkg}}}) {
+ foreach my $c (@{$files{$pkg . $vers{$pkg}}}) {
print "replaces: $c\n";
unlink "$vardir/methods/ftp/$dldir/$c";
}
diff --git a/dselect/methods/ftp/setup b/dselect/methods/ftp/setup
index 26da50d36..ae5d56571 100755
--- a/dselect/methods/ftp/setup
+++ b/dselect/methods/ftp/setup
@@ -123,15 +123,14 @@ sub download() {
my @dists = @{$_->[2]};
- my $dist;
- foreach $dist (@dists) {
+ foreach my $dist (@dists) {
my $dir = "$dist/binary-$arch";
print "Checking $dir...\n";
# if (!$ftp->pasv()) { print $ftp->message . "\n"; die 'error'; }
my @dirlst = $ftp->ls("$dir/");
my $got_pkgfile = 0;
- my $line = '';
- foreach $line (@dirlst) {
+
+ foreach my $line (@dirlst) {
if($line =~ /Packages/) {
$got_pkgfile=1;
}
diff --git a/dselect/methods/ftp/update b/dselect/methods/ftp/update
index 46bbdd872..56ff35f9e 100755
--- a/dselect/methods/ftp/update
+++ b/dselect/methods/ftp/update
@@ -84,9 +84,8 @@ foreach (@{$config{site}}) {
$config{proxypassword});
my @dists = @{$_->[2]};
- my $dist;
PACKAGE:
- foreach $dist (@dists) {
+ foreach my $dist (@dists) {
my $dir = "$dist/binary-$arch";
my $must_get = 0;
my $newest_pack_date;
@@ -238,9 +237,7 @@ EOM
if (!$packages_modified) {
print "No Packages files was updated.\n";
} else {
- my $file;
-
- foreach $file (@pkgfiles) {
+ foreach my $file (@pkgfiles) {
if (system('dpkg', '--merge-avail', $file)) {
print "Dpkg merge available failed on $file";
$exit = 1;
diff --git a/dselect/mkcurkeys.pl b/dselect/mkcurkeys.pl
index 2a70099ea..24f8b3d03 100755
--- a/dselect/mkcurkeys.pl
+++ b/dselect/mkcurkeys.pl
@@ -88,7 +88,7 @@ for my $i (33 .. 126) {
}
## no critic (BuiltinFunctions::ProhibitReverseSortBlock)
-for $k (sort {
+for my $k (sort {
looks_like_number($a) ?
looks_like_number($b) ? $a <=> $b : -1
: looks_like_number($b) ? 1 :