summaryrefslogtreecommitdiffstats
path: root/lib/smartmatch.pm
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2012-06-23 17:30:17 -0500
committerJesse Luehrs <doy@tozt.net>2012-06-23 17:35:24 -0500
commit4e296fd552b9fc1c23edcd7d2981d694a120d4e4 (patch)
treecf91658b0324be3f34a2a187b0a5ae44c821ce58 /lib/smartmatch.pm
parentefb4439ddf61def3dda4edd4af4b9c237e88d20f (diff)
downloadsmartmatch-4e296fd552b9fc1c23edcd7d2981d694a120d4e4.tar.gz
smartmatch-4e296fd552b9fc1c23edcd7d2981d694a120d4e4.zip
just store the engine name in the hint hash
Diffstat (limited to 'lib/smartmatch.pm')
-rw-r--r--lib/smartmatch.pm20
1 files changed, 9 insertions, 11 deletions
diff --git a/lib/smartmatch.pm b/lib/smartmatch.pm
index 0524799..ad3caaa 100644
--- a/lib/smartmatch.pm
+++ b/lib/smartmatch.pm
@@ -57,21 +57,19 @@ my $anon = 1;
sub import {
my $package = shift;
- my ($cb) = @_;
+ my ($engine) = @_;
- my $engine;
-
- if (ref($cb)) {
- $engine = 'smartmatch::engine::__ANON__::' . $anon;
- my $anon_stash = Package::Stash->new($engine);
+ if (ref($engine)) {
+ my $cb = $engine;
+ $engine = '__ANON__::' . $anon++;
+ my $anon_stash = Package::Stash->new("smartmatch::engine::$engine");
$anon_stash->add_symbol('&match' => $cb);
- $anon++;
}
else {
- $engine = "smartmatch::engine::$cb";
- use_package_optimistically($engine);
- die "$engine does not implement a 'match' function"
- unless $engine->can('match');
+ my $package = "smartmatch::engine::$engine";
+ use_package_optimistically($package);
+ die "$package does not implement a 'match' function"
+ unless $package->can('match');
}
register($engine);