summaryrefslogtreecommitdiffstats
path: root/lib/MooseX/Role
diff options
context:
space:
mode:
authordoy <doy@tozt.net>2008-12-07 00:33:20 -0500
committerdoy <doy@tozt.net>2008-12-07 00:33:20 -0500
commitf72f582111bb4da827ed4fb7a7ff855f6faf9786 (patch)
tree440a41e961908b5930a43c04930e24931695dd14 /lib/MooseX/Role
parent1f7c809af24762d7a1c0d1fab184a3ef1d8c54cd (diff)
downloadmoosex-role-matcher-f72f582111bb4da827ed4fb7a7ff855f6faf9786.tar.gz
moosex-role-matcher-f72f582111bb4da827ed4fb7a7ff855f6faf9786.zip
use $_ for passing the value to coderef matchers, rather than passing it as an argument
Diffstat (limited to 'lib/MooseX/Role')
-rw-r--r--lib/MooseX/Role/Matcher.pm7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/MooseX/Role/Matcher.pm b/lib/MooseX/Role/Matcher.pm
index b96ece5..fec35c8 100644
--- a/lib/MooseX/Role/Matcher.pm
+++ b/lib/MooseX/Role/Matcher.pm
@@ -29,7 +29,7 @@ use List::MoreUtils qw/any all/;
# does everyone's name start with either J or E?
Person->all_match([@people], name => [qr/^J/, qr/^E/]);
# find the first person whose name is 4 characters long (using the default)
- my $four = Person->first_match([@people], sub { length(shift) == 4 });
+ my $four = Person->first_match([@people], sub { length == 4 });
=head1 DESCRIPTION
@@ -104,7 +104,10 @@ method _match => sub {
return !defined $value if !defined $seek;
return 0 if !defined $value;
return $value =~ $seek if ref($seek) eq 'Regexp';
- return $seek->($value) if ref($seek) eq 'CODE';
+ if (ref($seek) eq 'CODE') {
+ local $_ = $value;
+ return $seek->();
+ }
if (ref($seek) eq 'ARRAY') {
for (@$seek) {
return 1 if $self->_match($value => $_);