Lexical::Importer - Importer + Lexical subs/vars.
This is a subclass of Importer which will import all symbols as lexicals instead of package symbols.
This imports symbols into the currently compiling scope which is not necessarily the same as the package doing the importing.
Say you have a module, Foo.pm
:
package Foo
use base 'Exporter';
our @EXPORT = qw/foo/;
sub foo { 'not lexical' }
You want to import foo()
to use, but you also have your own foo()
method
you do not want to squash in Your::Module.pm
# Define package versions first
sub foo { 'not lexical' }
say foo(); # prints 'not lexical';
{
use Lexical::Importer Foo => 'foo';
say foo(); # prints 'foo'
}
say foo(); # prints 'not lexical' again;
use Lexical::Importer Foo => 'foo';
say foo(); # prints 'foo'
say __PACKAGE__->foo(); # prints 'not lexical', method dispatch find package sub.
# Remove lexical subs
no Lexical::Importer;
say foo(); # prints 'not lexical' again;
This package inherits from Importer and works exactly the same apart from being lexical instead of modifying the symbol table.
Importer - The importer module this package subclasses
Lexical::Var and Lexical::Sub - The awesome modules Zefram wrote that make this possible. Note: Lexical::Importer ships with a forked copy of these
Lexical::Import - A similar module, but it does not support everything Lexical::Importer does.
The Lexical::Importer module is bundled with a fork of the Lexical::Var XS code. This fork is necessary due to Lexical::Var being broken on newer perls. The author of the original package is not accepting third party patches, and has not yet fixed the issues himself. Once a version of Lexical::Var ships with a fix for newer perls this fork will likely be removed.
Andrew Main (Zefram) [email protected]
Copyright (C) 2009, 2010, 2011, 2012, 2013 Andrew Main (Zefram) [email protected]
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The source code repository for Lexical-Importer can be found at
http://github.com/FIXME/
.
- Chad Granum [email protected]
- Chad Granum [email protected]
Copyright 2016 Chad Granum [email protected].
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://dev.perl.org/licenses/