From: Florian Ragwitz Date: Fri, 17 Oct 2008 03:18:34 +0000 (+0000) Subject: Instead of requiring by module name, generate the path and require() that. X-Git-Tag: 0.68~13 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a6844bfb972e5d883445dca38f1ca6cda868e3c6;p=gitmo%2FClass-MOP.git Instead of requiring by module name, generate the path and require() that. This doesn't generate confusing errors when loading '__PACKAGE__'. --- diff --git a/lib/Class/MOP.pm b/lib/Class/MOP.pm index b69bf51..d05de84 100644 --- a/lib/Class/MOP.pm +++ b/lib/Class/MOP.pm @@ -111,7 +111,9 @@ sub load_class { # if the class is not already loaded in the symbol table.. unless (is_class_loaded($class)) { # require it - my $e = do { local $@; eval "require $class"; $@ }; + my $file = $class . '.pm'; + $file =~ s{::}{/}g; + my $e = do { local $@; eval { require($file) }; $@ }; confess "Could not load class ($class) because : $e" if $e; }