From cf5ced804a7ad2c8d101a72d44a0068e69b51fe4 Mon Sep 17 00:00:00 2001 From: doy Date: Sat, 6 Dec 2008 22:58:45 -0500 Subject: clean up my confusion with @_ and $_ --- lib/MooseX/Role/Matcher.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/MooseX/Role') 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, @_); }; -- cgit v1.2.3-54-g00ecf