summaryrefslogtreecommitdiffstats
path: root/lib/smartmatch.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/smartmatch.pm')
-rw-r--r--lib/smartmatch.pm8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/smartmatch.pm b/lib/smartmatch.pm
index f464d95..fd15e03 100644
--- a/lib/smartmatch.pm
+++ b/lib/smartmatch.pm
@@ -21,7 +21,13 @@ __PACKAGE__->bootstrap(
sub import {
my $package = shift;
my ($cb) = @_;
- $cb = $cb->can('match') unless ref($cb);
+
+ if (!ref($cb)) {
+ my $engine = "smartmatch::engine::$cb";
+ eval "require $engine; 1"
+ or die "Couldn't load smartmatch engine $engine: $@";
+ $cb = $engine->can('match') unless ref($cb);
+ }
$^H ||= 0x020000; # HINT_LOCALIZE_HH