Subject: | Module::Load cannot import non-Exporter module |
Module::Load cannot import from non-Exporter module:
package A;
sub import { print "A::import\n"; }
$ perl -ale 'use Module::Load; load A'
should print:
A::import
prints:
<nothing>
I think the goto instead _export_to_level is proper solution.
Subject: | Module-Load-0.12.diff |
diff -Nru Module-Load-0.12.orig/lib/Module/Load.pm Module-Load-0.12/lib/Module/Load.pm
--- Module-Load-0.12.orig/lib/Module/Load.pm 2007-09-15 14:15:55.000000000 +0200
+++ Module-Load-0.12/lib/Module/Load.pm 2008-12-23 00:34:42.000000000 +0100
@@ -30,18 +30,13 @@
die $err if $err;
}
}
- __PACKAGE__->_export_to_level(1, $mod, @_) if @_;
-}
-
-### 5.004's Exporter doesn't have export_to_level.
-### Taken from Michael Schwerns Test::More and slightly modified
-sub _export_to_level {
- my $pkg = shift;
- my $level = shift;
- my $mod = shift;
- my $callpkg = caller($level);
-
- $mod->export($callpkg, @_);
+ { no strict 'refs';
+ my $import;
+ if (@_ and $import = $mod->can('import')) {
+ unshift @_, $mod;
+ goto &$import;
+ }
+ }
}
sub _to_file{