From d46ca6eacf7d512ac6d20dda977a4a33f9d4717c Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 7 Jul 2011 00:31:03 -0500 Subject: pure perl implementation of the core smartmatch algorithm --- lib/smartmatch.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/smartmatch.pm') 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 -- cgit v1.2.3-54-g00ecf