X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FImport-Into.git;a=blobdiff_plain;f=lib%2FImport%2FInto.pm;h=7ca9d0bc8062618649b0bcd90c12a01cc28d3ee1;hp=34ae9422f44d537efce55e79aa2466386e160f1c;hb=7a9ec1de996eb32a6fb07c942ae3c03744a82a17;hpb=6a91d2cb2c4774e42fb644aa795eaed30ab6d1fc diff --git a/lib/Import/Into.pm b/lib/Import/Into.pm index 34ae942..7ca9d0b 100644 --- a/lib/Import/Into.pm +++ b/lib/Import/Into.pm @@ -4,12 +4,12 @@ use strict; use warnings FATAL => 'all'; use Module::Runtime; -our $VERSION = '1.002003'; +our $VERSION = '1.002004'; sub _prelude { my $target = shift; my ($package, $file, $line, $level) - = ref $target ? @{$target}{qw(package filename line)} + = ref $target ? @{$target}{qw(package filename line level)} : $target =~ /[^0-9]/ ? ($target) : (undef, undef, undef, $target); if (defined $level) { @@ -25,9 +25,13 @@ sub _prelude { sub _make_action { my ($action, $target) = @_; my $version = ref $target && $target->{version}; - my $ver_check = $version ? ', $version' : ''; eval _prelude($target) - . qq{sub { Module::Runtime::use_module( shift$ver_check )->$action(\@_) }} + . q[sub {] + . q[ my $module = shift;] + . q[ Module::Runtime::require_module($module);] + . (ref $target && exists $target->{version} ? q[ $module->VERSION($version);] : q[]) + . q[ $module->].$action.q[(@_);] + . q[}] or die "Failed to build action sub to ${action} for ${target}: $@"; }