Acme-Given-Hash
view release on metacpan or search on metacpan
lib/Acme/Given/Hash.pm view on Meta::CPAN
return ref($ref) eq 'CODE' ? $ref->($key) : $ref;
}
# first check and see if we have an exact match
return RUN $self->{exact}->{$key} if exists $self->{exact}->{$key};
local $_ = $key; # allow match subs to just use $_;
foreach my $pair (@{ $self->{calculate} } ) {
my $match;
# 'string' ~~ [1..10] throws a warning, this disables this just for the check
{ no warnings qw{numeric};
# in the case of a sub as a key capture the return value
$match = ref($pair->{match}) eq 'CODE'
? $pair->{match}->($key)
: $key ~~ $pair->{match}
;
}
return RUN $pair->{value} if $match;
}
( run in 0.349 second using v1.01-cache-2.11-cpan-496ff517765 )