summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Granum <exodist7@gmail.com>2016-01-22 09:21:11 -0800
committerChad Granum <exodist7@gmail.com>2016-01-22 09:21:11 -0800
commit1f6a6a0f549aa2a16330f0699088b467e7b0cff5 (patch)
tree07f27aa2fa7445c08472fe44314fc5e4b98635bd
parentb7d7a886cfb8fe17bab62a7012c033ca37edfd78 (diff)
Fix bug on older perls, regen readme
-rw-r--r--Changes2
-rw-r--r--README250
-rw-r--r--README.md266
-rw-r--r--lib/Importer.pm6
4 files changed, 466 insertions, 58 deletions
diff --git a/Changes b/Changes
index d14a4ae..007c8d8 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,7 @@
{{$NEXT}}
+ - Fix for older perls
+
0.004 2016-01-21 21:18:11-08:00 America/Los_Angeles
- Finish testing
diff --git a/README b/README
index 3d57e9b..f83d370 100644
--- a/README
+++ b/README
@@ -51,7 +51,7 @@ WHY?
Using a modules import() for exporting makes it hard to give it other
purposes
- It is not unusual for a module to want to export symbols and prvide
+ It is not unusual for a module to want to export symbols and provide
import behaviors. It is also not unusual for a consumer to only want
1 or the other. Using this module you can import symbols without
also getting the "import()" side effects.
@@ -64,8 +64,8 @@ WHY?
its "import()" method.
There are other exporter modules on cpan
- This module normally assumes an Exporter uses Exporter, so it looks
- for the variables and method Exporter expects. However, other
+ This module normally assumes an exporter uses Exporter, so it looks
+ for the variables and methods Exporter expects. However, other
exporters on cpan can override this using the "IMPORTER_MENU()"
hook.
@@ -98,6 +98,29 @@ IMPORT PARAMETERS
defaults will be used.
SUPPORTED FEATURES
+ TAGS
+ You can define/import subsets of symbols using predefined tags.
+
+ use Importer 'Some::Thing' => ':tag';
+
+ /PATTERN/ or qr/PATTERN/
+ You can import all symbols that match a pattern. The pattern can be
+ supplied a string starting and ending with '/', or you can provide a
+ "qr/../" reference.
+
+ use Importer 'Some::Thing' => '/oo/';
+
+ use Importer 'Some::Thing' => qr/oo/;
+
+ EXLUDING SYMBOLS
+ You can exclude symbols by prefixing them with '!'.
+
+ use Importer 'Some::Thing'
+ '!foo', # Exclude one specific symbol
+ '!/pattern/', # Exclude all matching symbols
+ '!' => qr/oo/, # Exclude all that match the following arg
+ '!:tag'; # Exclude all in tag
+
RENAMING SYMBOLS AT IMPORT
*This is a new feature,* Exporter *does not support this on its own.*
@@ -118,11 +141,38 @@ SUPPORTED FEATURES
patterns that are specified for import, in which case the prefix/postfix
is applied to all symbols from the tag/patterm.
- @EXPORT_FAIL
- Use this to list subs that are not available on all platforms. If
- someone tries to import one of these, Importer will hit your "
- $from-"export_fail(@items) > callback to try to resolve the issue. See
- Exporter.pm for documentation of this feature.
+ UNIMPORTING
+ See "UNIMPORT PARAMETERS".
+
+ ANONYMOUS EXPORTS
+ See "%EXPORT_ANON".
+
+ GENERATED EXPORTS
+ See "%EXPORT_GEN".
+
+UNIMPORT PARAMETERS
+ no Importer; # Remove all subs brought in with Importer
+
+ no Importer qw/foo bar/; # Remove only the specified subs
+
+ Only subs can be unimported.
+
+ You can only unimport subs imported using Importer.
+
+SUPPORTED VARIABLES
+ @EXPORT
+ This is used exactly the way Exporter uses it.
+
+ List of symbols to export. Sigil is optional for subs. Symbols listed
+ here are exported by default. If possible you should put symbols in
+ @EXPORT_OK instead.
+
+ @EXPORT_OK
+ This is used exactly the way Exporter uses it.
+
+ List of symbols that can be imported. Sigil is optional for subs.
+ Symbols listed here are not exported by default. This is preferred over
+ @EXPORT.
%EXPORT_TAGS
This module supports tags exactly the way Exporter does.
@@ -131,32 +181,46 @@ SUPPORTED FEATURES
use Importer 'Other::Thing' => ':some_tag';
- /PATTERN/ or qr/PATTERN/
- You can import all symbols that match a pattern. The pattern can be
- supplied a string starting and ending with '/', or you can provide a
- "qr/../" reference.
+ @EXPORT_FAIL
+ This is used exactly the way Exporter uses it.
- use Importer 'Some::Thing' => '/oo/';
+ Use this to list subs that are not available on all platforms. If
+ someone tries to import one of these, Importer will hit your
+ "$from->export_fail(@items)" callback to try to resolve the issue. See
+ Exporter.pm for documentation of this feature.
- use Importer 'Some::Thing' => qr/oo/;
+ %EXPORT_ANON
+ This is new to this module, Exporter does not support it.
- EXLUDING SYMBOLS
- You can exlude symbols by prefixing them with '!'.
+ This allows you to export symbols that are not actually in your package
+ symbol table. The keys should be the symbol names, the values are the
+ references for the symbols.
- use Importer 'Some::Thing'
- '!foo', # Exclude one specific symbol
- '!/pattern/', # Exclude all matching symbols
- '!' => qr/oo/, # Exclude all that match the following arg
- '!:tag'; # Exclude all in tag
+ our %EXPORT_ANON = (
+ '&foo' => sub { 'foo' }
+ '$foo' => \$foo,
+ ...
+ );
-UNIMPORT PARAMETERS
- no Importer; # Remove all sub brought in with Importer
+ %EXPORT_GEN
+ This is new to this module, Exporter does not support it.
- no Importer qw/foo bar/; # Remove only the specified subs
+ This allows you to export symbols that are generated on export. The key
+ should be the name of a symbol. The value should be a coderef that
+ produces a reference that will be exported.
- Only subs can be unimported.
+ When the generators are called they will recieve 2 arguments, the
+ package the symbol is being exported into, and the symbol being imported
+ (name may or may not include sigil for subs).
- You can only unimport subs imported using Importer.
+ our %EXPORT_GEN = (
+ '&foo' => sub {
+ my ($into_package, $symbol_name) = @_;
+ ...
+ return sub { ... };
+ },
+ ...
+ );
CLASS METHODS
Importer->import($from)
@@ -180,6 +244,12 @@ CLASS METHODS
This lets you remove imported symbols from $from. $from my be a
package name, or a caller level.
+GIVING YOUR PACKAGE AN OLD-SCHOOL IMPORT METHOD
+ package My::Exporter;
+ use Importer Importer => ('exporter_import' => {-as => 'import'});
+
+ ...
+
USING WITH OTHER EXPORTER IMPLEMENTATIONS
If you want your module to work with Importer, but you use something
other than Exporter to define your exports, you can make it work be
@@ -196,13 +266,17 @@ USING WITH OTHER EXPORTER IMPLEMENTATIONS
export_ok => \@EXPORT_OK, # Other allowed exports
export_tags => \%EXPORT_TAGS, # Define tags
export_fail => \@EXPORT_FAIL, # For subs that may not always be available
+ export_anon => \%EXPORT_ANON, # Anonymous symbols to export
+
generate => \&GENERATE, # Sub to generate dynamic exports
+ # OR
+ export_gen => \%EXPORT_GEN, # Hash of builders, key is symbol
+ # name, value is sub that generates
+ # the symbol ref.
);
}
sub GENERATE {
- my $class = shift;
-
my ($symbol) = @_;
...
@@ -213,6 +287,126 @@ USING WITH OTHER EXPORTER IMPLEMENTATIONS
All exports must be listed in either @EXPORT or @EXPORT_OK to be
allowed. %EXPORT_TAGS, @EXPORT_FAIL, and "\&GENERATE" are optional.
+ Note: If your GENERATE sub needs the $class, $into, or $caller then your
+ "IMPORTER_MENU()" method will need to build an anonymous sub that closes
+ over them:
+
+ sub IMPORTER_MENU {
+ my $class = shift;
+ my ($into, $caller) = @_;
+
+ return (
+ ...
+ generate => sub { $class->GENERATE($into, $caller, @_) },
+ );
+ }
+
+OO Interface
+ use Importer;
+
+ my $imp = Importer->new(from => 'Some::Exporter');
+
+ $imp->do_import('Destination::Package');
+ $imp->do_import('Another::Destination', @symbols);
+
+ OBJECT CONSTRUCTION
+ $imp = Importer->new(from => 'Some::Exporter')
+ $imp = Importer->new(from => 'Some::Exporter', caller => [$package,
+ $file, $line])
+ This is how you create a new Importer instance. "from =>
+ 'Some::Exporter'" is the only required argument. You may also
+ specify the "caller => [...]" arrayref, which will be used only for
+ error reporting. If you do not specify a caller then Importer will
+ attempt to find the caller dynamically every time it needs it (this
+ is slow and expensive, but necessary if you intend to re-use the
+ object.)
+
+ OBJECT METHODS
+ $imp->do_import($into)
+ $imp->do_import($into, @symbols)
+ This will import from the objects "from" package into the $into
+ package. You can provide a list of @symbols, or you can leave it
+ empty for the defaults.
+
+ $imp->do_unimport()
+ $imp->do_unimport(@symbols)
+ This will remove imported symbols from the objects "from" package.
+ If you specify a list of @symbols then only the specified symbols
+ will be removed, otherwise all symbols imported using Importer will
+ be removed.
+
+ Note: Please be aware fo the difference between "do_import()" and
+ "do_unimport()". For import 'from' us used as the origin, in
+ unimport it is used as the target. This means you cannot re-use an
+ instance to import and then unimport.
+
+ ($into, $versions, $exclude, $symbols) =
+ $imp->parse_args('Dest::Package')
+ ($into, $versions, $exclude, $symbols) =
+ $imp->parse_args('Dest::Package', @symbols)
+ This parses arguments. The first argument must be the destination
+ package. Other arguments can be a mix of symbol names, tags,
+ patterns, version numbers, and exclusions.
+
+ $caller_ref = $imp->get_caller()
+ This will find the caller. This is mainly used for error reporting.
+ IF the object was constructed with a caller then that is what is
+ returned, otherwise this will scan the stack looking for the first
+ call that does not originate from a package that ISA Importer.
+
+ $imp->carp($warning)
+ Warn at the callers level.
+
+ $imp->croak($exception)
+ Die at the callers level.
+
+ $from_package = $imp->from()
+ Get the "from" package that was specified at construction.
+
+ $file = $imp->from_file()
+ Get the filename for the "from" package.
+
+ $imp->load_from()
+ This will load the "from" package if it has not been loaded already.
+ This uses some magic to ensure errors in the load process are
+ reported to the "caller".
+
+ $menu_hr = $imp->menu($into)
+ Get the export menu built from, or provided by the "from" package.
+ This is cached after the first time it is called. Use
+ "$imp->reload_menu()" to refresh it.
+
+ The menu structure looks like this:
+
+ $menu = {
+ # every valid export has a key in the lookup hashref, value is always
+ # 1, key always includes the sigil
+ lookup => {'&symbol_a' => 1, '$symbol_b' => 1, ...},
+
+ # most exports are listed here, symbol name with sigil is key, value is
+ # a reference to the symbol. If a symbol is missing it may be generated.
+ exports => {'&symbol_a' => \&symbol_a, '$symbol_b' => \$symbol_b, ...},
+
+ # Hashref of tags, tag name (without ':' prefix) is key, value is an
+ # arrayref of symbol names, subs may have a sigil, but are not required
+ # to.
+ tags => { DEFAULT => [...], foo => [...], ... },
+
+ # This is a hashref just like 'lookup'. Keys are symbols which may not
+ # always be available. If there are no symbols in this category then
+ # the value of the 'fail' key will be undef instead of a hashref.
+ fail => { '&iffy_symbol' => 1, '\&only_on_linux' => 1 },
+ # OR fail => undef,
+
+ # If present, this subroutine knows how to generate references for the
+ # symbols listed in 'lookup', but missing from 'exports'. References
+ # this returns are NEVER cached.
+ generate => sub { my $sym_name = shift; ...; return $symbol_ref },
+ };
+
+ $imp->reload_menu($into)
+ This will reload the export menu from the "from" package.
+
SOURCE
The source code repository for symbol can be found at
http://github.com/exodist/Importer.
diff --git a/README.md b/README.md
index a111a0b..5541522 100644
--- a/README.md
+++ b/README.md
@@ -57,7 +57,7 @@ addition to others.
- Using a modules import() for exporting makes it hard to give it other purposes
- It is not unusual for a module to want to export symbols and prvide import
+ It is not unusual for a module to want to export symbols and provide import
behaviors. It is also not unusual for a consumer to only want 1 or the other.
Using this module you can import symbols without also getting the `import()`
side effects.
@@ -70,8 +70,8 @@ addition to others.
- There are other exporter modules on cpan
- This module normally assumes an Exporter uses [Exporter](https://metacpan.org/pod/Exporter), so it looks for the
- variables and method [Exporter](https://metacpan.org/pod/Exporter) expects. However, other exporters on cpan can
+ This module normally assumes an exporter uses [Exporter](https://metacpan.org/pod/Exporter), so it looks for the
+ variables and methods [Exporter](https://metacpan.org/pod/Exporter) expects. However, other exporters on cpan can
override this using the `IMPORTER_MENU()` hook.
# COMPATABILITY
@@ -110,6 +110,31 @@ feature (like import renaming).
# SUPPORTED FEATURES
+## TAGS
+
+You can define/import subsets of symbols using predefined tags.
+
+ use Importer 'Some::Thing' => ':tag';
+
+## /PATTERN/ or qr/PATTERN/
+
+You can import all symbols that match a pattern. The pattern can be supplied a
+string starting and ending with '/', or you can provide a `qr/../` reference.
+
+ use Importer 'Some::Thing' => '/oo/';
+
+ use Importer 'Some::Thing' => qr/oo/;
+
+## EXLUDING SYMBOLS
+
+You can exclude symbols by prefixing them with '!'.
+
+ use Importer 'Some::Thing'
+ '!foo', # Exclude one specific symbol
+ '!/pattern/', # Exclude all matching symbols
+ '!' => qr/oo/, # Exclude all that match the following arg
+ '!:tag'; # Exclude all in tag
+
## RENAMING SYMBOLS AT IMPORT
_This is a new feature,_ [Exporter](https://metacpan.org/pod/Exporter) _does not support this on its own._
@@ -131,12 +156,44 @@ Using this syntax to set prefix and/or postfix also works on tags and patterns
that are specified for import, in which case the prefix/postfix is applied to
all symbols from the tag/patterm.
-## @EXPORT\_FAIL
+## UNIMPORTING
-Use this to list subs that are not available on all platforms. If someone tries
-to import one of these, Importer will hit your ` $from-`export\_fail(@items) >
-callback to try to resolve the issue. See [Exporter.pm](https://metacpan.org/pod/Exporter.pm) for documentation of
-this feature.
+See ["UNIMPORT PARAMETERS"](#unimport-parameters).
+
+## ANONYMOUS EXPORTS
+
+See ["%EXPORT\_ANON"](#export_anon).
+
+## GENERATED EXPORTS
+
+See ["%EXPORT\_GEN"](#export_gen).
+
+# UNIMPORT PARAMETERS
+
+ no Importer; # Remove all subs brought in with Importer
+
+ no Importer qw/foo bar/; # Remove only the specified subs
+
+**Only subs can be unimported**.
+
+**You can only unimport subs imported using Importer**.
+
+# SUPPORTED VARIABLES
+
+## @EXPORT
+
+This is used exactly the way [Exporter](https://metacpan.org/pod/Exporter) uses it.
+
+List of symbols to export. Sigil is optional for subs. Symbols listed here are
+exported by default. If possible you should put symbols in `@EXPORT_OK`
+instead.
+
+## @EXPORT\_OK
+
+This is used exactly the way [Exporter](https://metacpan.org/pod/Exporter) uses it.
+
+List of symbols that can be imported. Sigil is optional for subs. Symbols
+listed here are not exported by default. This is preferred over `@EXPORT`.
## %EXPORT\_TAGS
@@ -146,34 +203,49 @@ This module supports tags exactly the way [Exporter](https://metacpan.org/pod/Ex
use Importer 'Other::Thing' => ':some_tag';
-## /PATTERN/ or qr/PATTERN/
+## @EXPORT\_FAIL
-You can import all symbols that match a pattern. The pattern can be supplied a
-string starting and ending with '/', or you can provide a `qr/../` reference.
+This is used exactly the way [Exporter](https://metacpan.org/pod/Exporter) uses it.
- use Importer 'Some::Thing' => '/oo/';
+Use this to list subs that are not available on all platforms. If someone tries
+to import one of these, Importer will hit your `$from->export_fail(@items)`
+callback to try to resolve the issue. See [Exporter.pm](https://metacpan.org/pod/Exporter.pm) for documentation of
+this feature.
- use Importer 'Some::Thing' => qr/oo/;
+## %EXPORT\_ANON
-## EXLUDING SYMBOLS
+This is new to this module, [Exporter](https://metacpan.org/pod/Exporter) does not support it.
-You can exlude symbols by prefixing them with '!'.
+This allows you to export symbols that are not actually in your package symbol
+table. The keys should be the symbol names, the values are the references for
+the symbols.
- use Importer 'Some::Thing'
- '!foo', # Exclude one specific symbol
- '!/pattern/', # Exclude all matching symbols
- '!' => qr/oo/, # Exclude all that match the following arg
- '!:tag'; # Exclude all in tag
+ our %EXPORT_ANON = (
+ '&foo' => sub { 'foo' }
+ '$foo' => \$foo,
+ ...
+ );
-# UNIMPORT PARAMETERS
+## %EXPORT\_GEN
- no Importer; # Remove all sub brought in with Importer
+This is new to this module, [Exporter](https://metacpan.org/pod/Exporter) does not support it.
- no Importer qw/foo bar/; # Remove only the specified subs
+This allows you to export symbols that are generated on export. The key should
+be the name of a symbol. The value should be a coderef that produces a
+reference that will be exported.
-**Only subs can be unimported**.
+When the generators are called they will recieve 2 arguments, the package the
+symbol is being exported into, and the symbol being imported (name may or may
+not include sigil for subs).
-**You can only unimport subs imported using Importer**.
+ our %EXPORT_GEN = (
+ '&foo' => sub {
+ my ($into_package, $symbol_name) = @_;
+ ...
+ return sub { ... };
+ },
+ ...
+ );
# CLASS METHODS
@@ -202,6 +274,13 @@ You can exlude symbols by prefixing them with '!'.
This lets you remove imported symbols from `$from`. `$from` my be a package
name, or a caller level.
+# GIVING YOUR PACKAGE AN OLD-SCHOOL IMPORT METHOD
+
+ package My::Exporter;
+ use Importer Importer => ('exporter_import' => {-as => 'import'});
+
+ ...
+
# USING WITH OTHER EXPORTER IMPLEMENTATIONS
If you want your module to work with Importer, but you use something other than
@@ -218,13 +297,17 @@ to support Importer by putting this sub in your package:
export_ok => \@EXPORT_OK, # Other allowed exports
export_tags => \%EXPORT_TAGS, # Define tags
export_fail => \@EXPORT_FAIL, # For subs that may not always be available
+ export_anon => \%EXPORT_ANON, # Anonymous symbols to export
+
generate => \&GENERATE, # Sub to generate dynamic exports
+ # OR
+ export_gen => \%EXPORT_GEN, # Hash of builders, key is symbol
+ # name, value is sub that generates
+ # the symbol ref.
);
}
sub GENERATE {
- my $class = shift;
-
my ($symbol) = @_;
...
@@ -235,6 +318,135 @@ to support Importer by putting this sub in your package:
All exports must be listed in either `@EXPORT` or `@EXPORT_OK` to be allowed.
`%EXPORT_TAGS`, `@EXPORT_FAIL`, and `\&GENERATE` are optional.
+**Note:** If your GENERATE sub needs the `$class`, `$into`, or `$caller` then
+your `IMPORTER_MENU()` method will need to build an anonymous sub that closes
+over them:
+
+ sub IMPORTER_MENU {
+ my $class = shift;
+ my ($into, $caller) = @_;
+
+ return (
+ ...
+ generate => sub { $class->GENERATE($into, $caller, @_) },
+ );
+ }
+
+# OO Interface
+
+ use Importer;
+
+ my $imp = Importer->new(from => 'Some::Exporter');
+
+ $imp->do_import('Destination::Package');
+ $imp->do_import('Another::Destination', @symbols);
+
+## OBJECT CONSTRUCTION
+
+- $imp = Importer->new(from => 'Some::Exporter')
+- $imp = Importer->new(from => 'Some::Exporter', caller => \[$package, $file, $line\])
+
+ This is how you create a new Importer instance. `from => 'Some::Exporter'`
+ is the only required argument. You may also specify the `caller => [...]`
+ arrayref, which will be used only for error reporting. If you do not specify a
+ caller then Importer will attempt to find the caller dynamically every time it
+ needs it (this is slow and expensive, but necessary if you intend to re-use the
+ object.)
+
+## OBJECT METHODS
+
+- $imp->do\_import($into)
+- $imp->do\_import($into, @symbols)
+
+ This will import from the objects `from` package into the `$into` package.
+ You can provide a list of `@symbols`, or you can leave it empty for the
+ defaults.
+
+- $imp->do\_unimport()
+- $imp->do\_unimport(@symbols)
+
+ This will remove imported symbols from the objects `from` package. If you
+ specify a list of `@symbols` then only the specified symbols will be removed,
+ otherwise all symbols imported using Importer will be removed.
+
+ **Note:** Please be aware fo the difference between `do_import()` and
+ `do_unimport()`. For import 'from' us used as the origin, in unimport it is
+ used as the target. This means you cannot re-use an instance to import and then
+ unimport.
+
+- ($into, $versions, $exclude, $symbols) = $imp->parse\_args('Dest::Package')
+- ($into, $versions, $exclude, $symbols) = $imp->parse\_args('Dest::Package', @symbols)
+
+ This parses arguments. The first argument must be the destination package.
+ Other arguments can be a mix of symbol names, tags, patterns, version numbers,
+ and exclusions.
+
+- $caller\_ref = $imp->get\_caller()
+
+ This will find the caller. This is mainly used for error reporting. IF the
+ object was constructed with a caller then that is what is returned, otherwise
+ this will scan the stack looking for the first call that does not originate
+ from a package that ISA Importer.
+
+- $imp->carp($warning)
+
+ Warn at the callers level.
+
+- $imp->croak($exception)
+
+ Die at the callers level.
+
+- $from\_package = $imp->from()
+
+ Get the `from` package that was specified at construction.
+
+- $file = $imp->from\_file()
+
+ Get the filename for the `from` package.
+
+- $imp->load\_from()
+
+ This will load the `from` package if it has not been loaded already. This uses
+ some magic to ensure errors in the load process are reported to the `caller`.
+
+- $menu\_hr = $imp->menu($into)
+
+ Get the export menu built from, or provided by the `from` package. This is
+ cached after the first time it is called. Use `$imp->reload_menu()` to
+ refresh it.
+
+ The menu structure looks like this:
+
+ $menu = {
+ # every valid export has a key in the lookup hashref, value is always
+ # 1, key always includes the sigil
+ lookup => {'&symbol_a' => 1, '$symbol_b' => 1, ...},
+
+ # most exports are listed here, symbol name with sigil is key, value is
+ # a reference to the symbol. If a symbol is missing it may be generated.
+ exports => {'&symbol_a' => \&symbol_a, '$symbol_b' => \$symbol_b, ...},
+
+ # Hashref of tags, tag name (without ':' prefix) is key, value is an
+ # arrayref of symbol names, subs may have a sigil, but are not required
+ # to.
+ tags => { DEFAULT => [...], foo => [...], ... },
+
+ # This is a hashref just like 'lookup'. Keys are symbols which may not
+ # always be available. If there are no symbols in this category then
+ # the value of the 'fail' key will be undef instead of a hashref.
+ fail => { '&iffy_symbol' => 1, '\&only_on_linux' => 1 },
+ # OR fail => undef,
+
+ # If present, this subroutine knows how to generate references for the
+ # symbols listed in 'lookup', but missing from 'exports'. References
+ # this returns are NEVER cached.
+ generate => sub { my $sym_name = shift; ...; return $symbol_ref },
+ };
+
+- $imp->reload\_menu($into)
+
+ This will reload the export menu from the `from` package.
+
# SOURCE
The source code repository for symbol can be found at
diff --git a/lib/Importer.pm b/lib/Importer.pm
index b353cfe..a92f82e 100644
--- a/lib/Importer.pm
+++ b/lib/Importer.pm
@@ -2,7 +2,7 @@ package Importer;
use strict;
use warnings;
-our $VERSION = 0.004;
+our $VERSION = 0.005;
my %SIG_TO_SLOT = (
'&' => 'CODE',
@@ -508,7 +508,7 @@ sub _set_symbols {
# on they will not.
BEGIN { \${^WARNING_BITS} = \$caller->[9] if defined \$caller->[9] }
#line $caller->[2] "$caller->[1]"
-sub { *{"$into\::\$_[0]"} = \$_[1] }
+sub { *{"$into\\::\$_[0]"} = \$_[1] }
EOT
use strict 'refs';
@@ -617,7 +617,7 @@ sub _optimal_import {
# their import redefines things.
BEGIN { \${^WARNING_BITS} = \$caller->[9] if defined \$caller->[9] };
#line $caller->[2] "$caller->[1]"
-(*{"\$into\::\$_"} = \$final{\$_}, push \@{\$IMPORTED->{\$into}} => \$_) for keys %final;
+(*{"$into\\::\$_"} = \$final{\$_}, push \@{\$IMPORTED->{\$into}} => \$_) for keys %final;
1;
EOT
}