diff options
author | Jesse Luehrs <doy@tozt.net> | 2013-07-10 17:11:20 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-07-10 17:11:20 -0400 |
commit | 5c9420df616f091d317fda0c0fce38359f736da6 (patch) | |
tree | 438df66d6f96b66a79c35d6618416cecb7023748 /lib | |
parent | 51601b722cbd7c582f5ed2e163ed12b3d5cfb527 (diff) | |
download | exporter-lexical-5c9420df616f091d317fda0c0fce38359f736da6.tar.gz exporter-lexical-5c9420df616f091d317fda0c0fce38359f736da6.zip |
allow just building the exporter without installing it
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Exporter/Lexical.pm | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/Exporter/Lexical.pm b/lib/Exporter/Lexical.pm index 0a1ea5a..633da52 100644 --- a/lib/Exporter/Lexical.pm +++ b/lib/Exporter/Lexical.pm @@ -47,12 +47,24 @@ sub import { my $caller = caller; - my $import = sub { + my $import = build_exporter(\%opts, $caller); + + { + no strict 'refs'; + *{ $caller . '::import' } = $import; + } +} + +sub build_exporter { + my ($opts, $caller) = @_; + $caller //= caller; + + return sub { my $caller_stash = do { no strict 'refs'; \%{ $caller . '::' }; }; - my @exports = @{ $opts{'-exports'} }; + my @exports = @{ $opts->{'-exports'} }; my %exports = map { $_ => \&{ $caller_stash->{$_} } } @exports; for my $export (keys %exports) { @@ -65,11 +77,6 @@ sub import { # for now by injecting a dummy statement right after the 'use'. _lex_stuff(";1;"); }; - - { - no strict 'refs'; - *{ $caller . '::import' } = $import; - } } =head1 BUGS |