summaryrefslogtreecommitdiffstats
path: root/lib/smartmatch.pm
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-07-07 00:31:03 -0500
committerJesse Luehrs <doy@tozt.net>2011-07-07 00:31:03 -0500
commitd46ca6eacf7d512ac6d20dda977a4a33f9d4717c (patch)
treedb47ad2bbd9e8515ff292afa22966e04e424588c /lib/smartmatch.pm
parent4a1aaf32fde2658905f84ffb76708d7ffe53480f (diff)
downloadsmartmatch-engine-rjbs-d46ca6eacf7d512ac6d20dda977a4a33f9d4717c.tar.gz
smartmatch-engine-rjbs-d46ca6eacf7d512ac6d20dda977a4a33f9d4717c.zip
pure perl implementation of the core smartmatch algorithm
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