fix pragmas from "importing" leaking into outer scopes
[p5sagit/Package-Variant.git] / lib / Package / Variant.pm
index bc76781..8ff3f56 100644 (file)
@@ -2,10 +2,10 @@ package Package::Variant;
 
 use strictures 1;
 use Import::Into;
-use Module::Runtime qw(use_module);
+use Module::Runtime qw(require_module);
 use Carp qw(croak);
 
-our $VERSION = '1.001003'; # 1.1.3
+our $VERSION = '1.001004'; # 1.1.4
 
 $VERSION = eval $VERSION;
 
@@ -96,7 +96,9 @@ sub build_variant_of {
   my $variant_name = "${variable}::_Variant_".++$Variable{$variable}{anon};
   foreach my $to_import (@{$Variable{$variable}{args}{importing}}) {
     my ($pkg, $args) = @$to_import;
-    use_module($pkg)->import::into($variant_name, @{$args});
+    require_module $pkg;
+    eval q{ BEGIN { $pkg->import::into($variant_name, @{$args}) }; 1; }
+      or die $@;
   }
   my $subs = $Variable{$variable}{subs};
   local @{$subs}{keys %$subs} = map $variant_name->can($_), keys %$subs;
@@ -161,7 +163,7 @@ This module allows you to build packages that return different variations
 depending on what parameters are given.
 
 Users of your package will receive a subroutine able to take parameters
-and return the name of a suitable variant package. The implmenetation does
+and return the name of a suitable variant package. The implementation does
 not care about what kind of package it builds.
 
 =head2 Declaring a variable package
@@ -235,7 +237,7 @@ subroutine under a different name by specifying an C<as> argument.
 
 For regular uses, the L<normal import|/Using variable packages> provides
 more than enough flexibility. However, if you want to create variations of
-dynamically determined packages, you can use the L</build_variation_of>
+dynamically determined packages, you can use the L</build_variant_of>
 method.
 
 You can use this to create variations of other packages and pass arguments
@@ -285,7 +287,7 @@ also pass a string instead:
 An array reference of strings listing the names of subroutines that should
 be proxied. These subroutines are expected to be installed into the new
 variant package by the modules imported with L</importing>. Subroutines
-with the same name will be availabe in your declaration package, and will
+with the same name will be available in your declaration package, and will
 proxy through to the newly created package when used within
 L</make_variant>.
 
@@ -331,10 +333,10 @@ Exports the generator subroutine under a different name than the default.
 
 These methods are available on C<Package::Variant> itself.
 
-=head2 build_variation_of
+=head2 build_variant_of
 
   my $variant_package = Package::Variant
-    ->build_variation_of($variable_package, @arguments);
+    ->build_variant_of($variable_package, @arguments);
 
 This is the dynamic method of creating new variants. It takes the
 C<$variable_package>, which is a pre-declared variable package, and a set