The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Importer::Zim - Import functions without namespace pollution

VERSION

version 0.10.1

SYNOPSIS

    use Importer::Zim 'Scalar::Util' => 'blessed';
    use Importer::Zim 'Scalar::Util' => 'blessed' => { -as => 'typeof' };

    use Importer::Zim 'Mango::BSON' => ':bson';

    use Importer::Zim 'Foo' => { -version => '3.0' } => 'foo';

    use Importer::Zim 'SpaceTime::Machine' => [qw(robot rubber_pig)];

DESCRIPTION

   "Because, when you create a giant monster of doom,
   no matter how cute, you have to... you have to... I don't know."
     – Zim

This pragma imports subroutines from other modules in a clean way. "Clean imports" here mean that the imported symbols will be available for compilation and will not pollute the user namespace at runtime.

Importer::Zim relies on pluggable backends which give a precise meaning to "clean imports". For example, Importer::Zim::Lexical uses lexical subs that are bound to the surrounding lexical scope and never touch the target namespace.

By default, Importer::Zim looks at package variables @EXPORT, @EXPORT_OK and %EXPORT_TAGS to decide what are exportable subroutines. It tries its best to implement a behavior akin to Exporter without the corresponding namespace pollution.

BACKENDS

Importer::Zim will try the following backends in order until one succeeds to load.

Read also "WHICH BACKEND?" in Importer::Zim::Cookbook.

METHODS

import

    Importer::Zim->import($class => @imports);
    Importer::Zim->import($class => \%opts => @imports);

FUNCTIONS

export_to

    Importer::Zim::export_to($target, %imports);
    Importer::Zim::export_to($target, \%imports);

DEBUGGING

You can set the IMPORTER_ZIM_DEBUG environment variable to get some diagnostics information printed to STDERR.

    IMPORTER_ZIM_DEBUG=1

SEE ALSO

zim

Importer::Zim::Cookbook

Importer and Lexical::Importer

lexically

AUTHOR

Adriano Ferreira <ferreira@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2017-2018 by Adriano Ferreira.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.