From c7253523e977559d659d0cb6dad0bfe414e32a42 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Mon, 13 Nov 2006 09:37:35 +0000 Subject: cleanup: declare variables where they are needed --- urpm.pm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/urpm.pm b/urpm.pm index 392207f2..02c9a11f 100644 --- a/urpm.pm +++ b/urpm.pm @@ -2365,8 +2365,7 @@ sub get_packages_list { #- associated to a null list. sub get_source_packages { my ($urpm, $packages, %options) = @_; - my ($id, $error, @list_error, %protected_files, %local_sources, @list, %fullname2id, %file2fullnames, %examined); - local $_; + my (%protected_files, %local_sources, %fullname2id); #- build association hash to retrieve id and examine all list files. foreach (keys %$packages) { @@ -2381,6 +2380,7 @@ sub get_source_packages { #- examine each medium to search for packages. #- now get rpm file name in hdlist to match list file. + my %file2fullnames; foreach my $pkg (@{$urpm->{depslist} || []}) { $file2fullnames{$pkg->filename}{$pkg->fullname} = undef; } @@ -2397,7 +2397,7 @@ sub get_source_packages { next; } elsif (keys(%{$file2fullnames{$filename} || {}}) == 1) { my ($fullname) = keys(%{$file2fullnames{$filename} || {}}); - if (defined($id = delete $fullname2id{$fullname})) { + if (defined(my $id = delete $fullname2id{$fullname})) { $local_sources{$id} = $filepath; } else { $options{clean_other} && ! exists $protected_files{$filepath} and unlink $filepath; @@ -2415,6 +2415,8 @@ sub get_source_packages { #- clean download directory, do it here even if this is not the best moment. clean_dir("$urpm->{cachedir}/partial") if $options{clean_all}; + my ($error, @list_error, @list, %examined); + foreach my $medium (@{$urpm->{media} || []}) { my (%sources, %list_examined, $list_warning); @@ -2440,7 +2442,7 @@ sub get_source_packages { next; } elsif (keys(%{$file2fullnames{$filename} || {}}) == 1) { my ($fullname) = keys(%{$file2fullnames{$filename} || {}}); - if (defined($id = $fullname2id{$fullname})) { + if (defined(my $id = $fullname2id{$fullname})) { if (!/\.delta\.rpm$/ || $urpm->is_delta_installable($urpm->{depslist}[$id], $options{root})) { $sources{$id} = $medium->{virtual} ? "$medium->{url}/$_" : $_; } @@ -2474,7 +2476,7 @@ sub get_source_packages { my ($fullname) = keys(%{$file2fullnames{$fi} || {}}); unless (exists($list_examined{$fullname})) { ++$list_warning; - if (defined($id = $fullname2id{$fullname})) { + if (defined(my $id = $fullname2id{$fullname})) { if ($fi !~ /\.delta\.rpm$/ || $urpm->is_delta_installable($urpm->{depslist}[$id], $options{root})) { $sources{$id} = "$medium->{url}/" . $fi; } -- cgit v1.2.1