diff options
author | doy <doy@tozt.net> | 2008-12-06 22:58:45 -0500 |
---|---|---|
committer | doy <doy@tozt.net> | 2008-12-06 22:58:45 -0500 |
commit | cf5ced804a7ad2c8d101a72d44a0068e69b51fe4 (patch) | |
tree | 07986b35fc04f529c55c78b54aca90b2d7e8c192 | |
parent | 2538b5c23b461f63b26dd48019ac896a3d16b0d9 (diff) | |
download | moosex-role-matcher-cf5ced804a7ad2c8d101a72d44a0068e69b51fe4.tar.gz moosex-role-matcher-cf5ced804a7ad2c8d101a72d44a0068e69b51fe4.zip |
clean up my confusion with @_ and $_
-rw-r--r-- | lib/MooseX/Role/Matcher.pm | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/MooseX/Role/Matcher.pm b/lib/MooseX/Role/Matcher.pm index 6456031..bfb658e 100644 --- a/lib/MooseX/Role/Matcher.pm +++ b/lib/MooseX/Role/Matcher.pm @@ -17,8 +17,9 @@ method _apply_to_matches => sub { my $class = shift; my $on_match = shift; my @list = @{ shift() }; - unshift @_, $default if (@_ % 2 == 1); - $on_match->(sub { $_->match(@_) }, @list); + my @matchers = @_; + unshift @matchers, $default if (@_ % 2 == 1); + $on_match->(sub { $_->match(@matchers) }, @list); }; method first_match => sub { @@ -34,7 +35,7 @@ method each_match => sub { method grep_matches => sub { my $class = shift; - my $grep = sub { my $code = shift; grep { $code->($_) } @_ }; + my $grep = sub { my $code = shift; grep { $code->() } @_ }; $class->_apply_to_matches($grep, @_); }; |