[libconfig-model-dpkg-perl] 24/36: DpkgSyntax: don't use $_ in a big loop

dod at debian.org dod at debian.org
Sat Oct 17 16:27:15 UTC 2015


This is an automated email from the git hooks/post-receive script.

dod pushed a commit to branch master
in repository libconfig-model-dpkg-perl.

commit 15375d155610702df9d670ba613b025c7c909edb
Author: Dominique Dumont <dod at debian.org>
Date:   Thu Oct 15 21:04:25 2015 +0200

    DpkgSyntax: don't use $_ in a big loop
    
    Gbp-Dch: Ignore
---
 lib/Config/Model/Backend/DpkgSyntax.pm | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/lib/Config/Model/Backend/DpkgSyntax.pm b/lib/Config/Model/Backend/DpkgSyntax.pm
index 83c9f59..dbce871 100644
--- a/lib/Config/Model/Backend/DpkgSyntax.pm
+++ b/lib/Config/Model/Backend/DpkgSyntax.pm
@@ -42,20 +42,20 @@ sub parse_dpkg_lines {
     # [keyword, [ value, line_nb, altered , comment ] ])
     my @res ; 
     
-    foreach (@$lines) {
-        $logger->trace("Parsing line $line_nb '$_'");
-        if (/^#/) { # comment are always located before the keyword (hopefully)
+    foreach my $l (@$lines) {
+        $logger->trace("Parsing line $line_nb '$l'");
+        if ( $l =~ /^#/ ) { # comment are always located before the keyword (hopefully)
             Config::Model::Exception::Syntax->throw (
                 object => $self,
                 parsed_line => $line_nb,
                 message => "Comments are not allowed",
             ) unless $comment_allowed;
-            my $c = $_ ;
+            my $c = $l ;
             $c =~ s/#\s// ;
             push @comments, $c ;
         }
-        elsif (/^([\w\-]+)\s*:/) {  # keyword: 
-            my ($field,$text) = split /\s*:\s*/,$_,2 ;
+        elsif ( $l =~ /^([\w\-]+)\s*:/ ) {  # keyword:
+            my ($field,$text) = split /\s*:\s*/,$l,2 ;
             $text =~ s/\s+$//;
             $key = $field ;
             $logger->trace("line $line_nb start new field $key with '$text'");
@@ -67,8 +67,8 @@ sub parse_dpkg_lines {
             @comments = () ;
             $store_ref = \$store_list->[$#$store_list][0] ;
         }
-        elsif ($key and /^\s*$/) {     # first empty line after a section
-            $logger->trace("empty line: starting new section");
+        elsif ( $key and $l =~ /^\s*$/ ) {     # first empty line after a section
+            $logger->trace("empty line $line_nb: starting new section");
             $key = '';
             push @res, $section_line, $store_list if @$store_list ; # don't store empty sections 
             $store_list = [] ;
@@ -76,24 +76,24 @@ sub parse_dpkg_lines {
             chomp $$store_ref if defined $$store_ref; # remove trailing \n
             undef $store_ref ; # to ensure that next line contains a keyword
         }
-        elsif (/^\s*$/) {     # "extra" empty line
-            $handle_garbage->($_, $line_nb) if $handle_garbage ;
+        elsif ( $l =~ /^\s*$/ ) {     # "extra" empty line
+            $handle_garbage->($l, $line_nb) if $handle_garbage ;
             $logger->trace("extra empty line: skipped");
             # just skip it
         } 
-        elsif (/^\s+\.$/) {   # line with a single dot
+        elsif ( $l =~ /^\s+\.$/) {   # line with a single dot
             $logger->trace("dot line: adding blank line to field $key");
             _store_line($store_ref,"",$check,$line_nb) ;
         }
-        elsif (s/^\s//) {     # non empty line
-            $logger->trace("text line: adding '$_' to field $key");
-            _store_line($store_ref,$_ , $check,$line_nb);
+        elsif ( $l =~ s/^\s//) {     # non empty line
+            $logger->trace("text line: adding '$l' to field $key");
+            _store_line($store_ref,$l , $check,$line_nb);
         }
         elsif ($handle_garbage) {
-            $handle_garbage->($_, $line_nb) ;
+            $handle_garbage->($l, $line_nb) ;
         }
         else {
-            my $msg = "DpkgSyntax error: Invalid line (missing ':' ?) : $_" ;
+            my $msg = "DpkgSyntax error: Invalid line (missing ':' ?) : $l" ;
             Config::Model::Exception::Syntax -> throw ( message => $msg, parsed_line => $line_nb ) 
                 if $check eq 'yes' ; 
             $logger->error($msg) if $check eq 'skip';

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libconfig-model-dpkg-perl.git



More information about the Pkg-perl-cvs-commits mailing list