[libmarpa-r2-perl] 04/05: Eliminate use of Perl's each keyword

Jonas Smedegaard dr at jones.dk
Sat May 17 21:24:04 UTC 2014


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

js pushed a commit to annotated tag Marpa-R2-2.085_000
in repository libmarpa-r2-perl.

commit 668a2b332ea84fbaf856b819d76b14ff1affa9ad
Author: Jeffrey Kegler <JKEGL at cpan.org>
Date:   Wed Apr 2 20:54:05 2014 -0700

    Eliminate use of Perl's each keyword
---
 cpan/lib/Marpa/R2/Grammar.pm    | 9 +++++----
 cpan/lib/Marpa/R2/Recognizer.pm | 3 ++-
 cpan/pperl/Marpa/R2/Perl.pm     | 5 +++--
 cpan/t/code_diag.t              | 5 +++--
 cpan/t/randal.t                 | 5 +++--
 cpan/t/timeflies.t              | 5 +++--
 6 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/cpan/lib/Marpa/R2/Grammar.pm b/cpan/lib/Marpa/R2/Grammar.pm
index 7079822..3919ddf 100644
--- a/cpan/lib/Marpa/R2/Grammar.pm
+++ b/cpan/lib/Marpa/R2/Grammar.pm
@@ -1300,12 +1300,13 @@ sub add_user_rule {
     my $keep_separation   = 0;
     my $description;
 
-    OPTION: while ( my ( $option, $value ) = each %{$options} ) {
+    OPTION: for my $option ( keys %{$options} ) {
+        my $value = $options->{$option};
         if ( $option eq 'name' )   { $rule_name = $value; next OPTION; }
         if ( $option eq 'rhs' )    { $rhs_names = $value; next OPTION }
         if ( $option eq 'lhs' )    { $lhs_name  = $value; next OPTION }
         if ( $option eq 'action' ) { $action    = $value; next OPTION }
-        if ( $option eq 'bless' ) { $blessing    = $value; next OPTION }
+        if ( $option eq 'bless' )  { $blessing  = $value; next OPTION }
         if ( $option eq 'rank' )   { $rank      = $value; next OPTION }
         if ( $option eq 'null_ranking' ) {
             $null_ranking = $value;
@@ -1321,10 +1322,10 @@ sub add_user_rule {
             next OPTION;
         }
         if ( $option eq 'keep' ) { $keep_separation = $value; next OPTION }
-        if ( $option eq 'mask' ) { $mask = $value; next OPTION }
+        if ( $option eq 'mask' ) { $mask            = $value; next OPTION }
         if ( $option eq 'description' ) { $description = $value; next OPTION }
         Marpa::R2::exception("Unknown user rule option: $option");
-    } ## end OPTION: while ( my ( $option, $value ) = each %{$options} )
+    } ## end OPTION: for my $option ( keys %{$options} )
 
     if ( defined $min and not Scalar::Util::looks_like_number($min) ) {
         Marpa::R2::exception(
diff --git a/cpan/lib/Marpa/R2/Recognizer.pm b/cpan/lib/Marpa/R2/Recognizer.pm
index 880e1ef..c122626 100644
--- a/cpan/lib/Marpa/R2/Recognizer.pm
+++ b/cpan/lib/Marpa/R2/Recognizer.pm
@@ -404,7 +404,8 @@ sub Marpa::R2::Recognizer::set {
             }
             my $closures =
                 $recce->[Marpa::R2::Internal::Recognizer::CLOSURES] = $value;
-            while ( my ( $action, $closure ) = each %{$closures} ) {
+            for my $action ( keys %{$closures} ) {
+                my $closure = $closures->{$action};
                 Marpa::R2::exception(qq{Bad closure for action "$action"})
                     if ref $closure ne 'CODE';
             }
diff --git a/cpan/pperl/Marpa/R2/Perl.pm b/cpan/pperl/Marpa/R2/Perl.pm
index aeccc6f..c0954ab 100644
--- a/cpan/pperl/Marpa/R2/Perl.pm
+++ b/cpan/pperl/Marpa/R2/Perl.pm
@@ -1056,13 +1056,14 @@ sub Marpa::R2::Perl::read_tokens {
     $hash_arg //= {};
 
     my @recce_args = ();
-    HASH_ARG: while ( my ( $arg, $value ) = each %{$hash_arg} ) {
+    HASH_ARG: for my $arg ( keys %{$hash_arg} ) {
+        my $value = $hash_arg->{$arg};
         if ( grep { $_ eq $arg } @RECCE_NAMED_ARGUMENTS ) {
             push @recce_args, $arg, $value;
             next HASH_ARG;
         }
         Carp::croak("Unknown hash arg: $arg");
-    } ## end HASH_ARG: while ( my ( $arg, $value ) = each %{$hash_arg} )
+    } ## end HASH_ARG: for my $arg ( keys %{$hash_arg} )
 
     my $grammar = $parser->{grammar};
 
diff --git a/cpan/t/code_diag.t b/cpan/t/code_diag.t
index af4539c..727809d 100644
--- a/cpan/t/code_diag.t
+++ b/cpan/t/code_diag.t
@@ -251,7 +251,8 @@ sub run_test {
     ### e_op_action default: $e_op_action
     ### e_number_action default: $e_number_action
 
-    ARG: while ( my ( $arg, $value ) = each %{$args} ) {
+    ARG: for my $arg ( keys %{$args} ) {
+        my $value        = $args->{$arg};
         my $run_test_arg = lc $arg;
         if ( $run_test_arg eq 'e_op_action' ) {
             $e_op_action = $value;
@@ -266,7 +267,7 @@ sub run_test {
             next ARG;
         }
         die "unknown argument to run_test: $arg";
-    } ## end ARG: while ( my ( $arg, $value ) = each %{$args} )
+    } ## end ARG: for my $arg ( keys %{$args} )
 
     ### e_op_action: $e_op_action
     ### e_number_action: $e_number_action
diff --git a/cpan/t/randal.t b/cpan/t/randal.t
index cb910c5..034c4f8 100644
--- a/cpan/t/randal.t
+++ b/cpan/t/randal.t
@@ -223,7 +223,8 @@ TEST: for my $test_data (@test_data) {
                 $pos );
         } ## end TOKEN: for my $token (@expected_symbols)
 
-        TOKEN_TYPE: while ( my ( $token, $regex ) = each %regexes ) {
+        TOKEN_TYPE: for my $token ( keys %regexes ) {
+            my $regex = $regexes{$token};
             next TOKEN_TYPE
                 if not grep { $token eq $_ } @{$terminals_expected};
             pos $test_input = $pos;
@@ -234,7 +235,7 @@ TEST: for my $test_data (@test_data) {
             $recce->alternative( $token, \$+{match},
                 ( ( pos $test_input ) - $pos ) );
 
-        } ## end TOKEN_TYPE: while ( my ( $token, $regex ) = each %regexes )
+        } ## end TOKEN_TYPE: for my $token ( keys %regexes )
         $recce->earleme_complete();
         $terminals_expected = $recce->terminals_expected();
     } ## end for ( my $pos = 0; $pos < $input_length; $pos++ )
diff --git a/cpan/t/timeflies.t b/cpan/t/timeflies.t
index af821fe..fcacb69 100644
--- a/cpan/t/timeflies.t
+++ b/cpan/t/timeflies.t
@@ -96,11 +96,12 @@ my %lexical_class = (
     'article_lex'        => 'a an',
 );
 my %vocabulary = ();
-while ( my ( $lexical_class, $words ) = each %lexical_class ) {
+for my $lexical_class (keys %lexical_class) {
+    my $words = $lexical_class{$lexical_class};
     for my $word ( split q{ }, $words ) {
         push @{ $vocabulary{$word} }, $lexical_class;
     }
-}
+} ## end for my $lexical_class (%lexical_class)
 
 for my $data ( 'time flies like an arrow', 'fruit flies like a banana' ) {
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmarpa-r2-perl.git



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