This is an automated email from the git hooks/post-receive script. intrigeri pushed a commit to annotated tag 0.22 in repository libtest-bdd-cucumber-perl.
commit 2391a6d9a22b4d1f6dfc8754b6fc92833c3b81e9 Author: Paul Cochrane <p...@liekut.de> Date: Wed Jun 4 12:02:55 2014 +0200 Removing $_ modifications in list functions According to PBP, modifying $_ within map, grep or first is *really* not a good idea, since $_ gets aliased within the list function, thus unexpected things can occur. One recommendation in PBP is to simply modify a copy of each list element and thus avoid the problem (this is the solution presented in this commit). Alternatively, one could rewrite the map/grep/first as a for loop, thus making the side-effects more explicit. Here is how that would look in _build_transformed_matches(): my @newly_transformed_matches; for my $match ( @transformed_matches ) { push @newly_transformed_matches, $self->transform( $match ); } @transformed_matches = @newly_transformed_matches; This does the same thing (i.e. the tests pass, and Devel::Cover tells me that the code is exercised by the tests) and may be more readable/maintainable depending upon one's point of view. --- lib/Test/BDD/Cucumber/Parser.pm | 2 +- lib/Test/BDD/Cucumber/StepContext.pm | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Test/BDD/Cucumber/Parser.pm b/lib/Test/BDD/Cucumber/Parser.pm index d05d52c..e8249a5 100644 --- a/lib/Test/BDD/Cucumber/Parser.pm +++ b/lib/Test/BDD/Cucumber/Parser.pm @@ -327,7 +327,7 @@ sub _pipe_array { my ( $self, $string ) = @_; my @atoms = split(/\|/, $string); shift( @atoms ); - return map { $_ =~ s/^\s+//; $_ =~ s/\s+$//; $_ } @atoms; + return map { my $atom = $_; $atom =~ s/^\s+//; $atom =~ s/\s+$//; $atom } @atoms; } 1; diff --git a/lib/Test/BDD/Cucumber/StepContext.pm b/lib/Test/BDD/Cucumber/StepContext.pm index 4fe75e3..45e9fb3 100644 --- a/lib/Test/BDD/Cucumber/StepContext.pm +++ b/lib/Test/BDD/Cucumber/StepContext.pm @@ -244,7 +244,10 @@ sub _build_transformed_matches if ( $self->verb ne 'transform' and $self->has_transformers ) { - @transformed_matches = map { $_ = $self->transform( $_ ) } @transformed_matches; + @transformed_matches = map { + my $match = $_; + $match = $self->transform( $match ); + } @transformed_matches; } return \@transformed_matches; -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libtest-bdd-cucumber-perl.git _______________________________________________ Pkg-perl-cvs-commits mailing list Pkg-perl-cvs-commits@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits