Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

module::loaded5.18(3pm) [mojave man page]

Module::Loaded(3pm)					 Perl Programmers Reference Guide				       Module::Loaded(3pm)

NAME
Module::Loaded - mark modules as loaded or unloaded SYNOPSIS
use Module::Loaded; $bool = mark_as_loaded('Foo'); # Foo.pm is now marked as loaded $loc = is_loaded('Foo'); # location of Foo.pm set to the # loaders location eval "require 'Foo'"; # is now a no-op $bool = mark_as_unloaded('Foo'); # Foo.pm no longer marked as loaded eval "require 'Foo'"; # Will try to find Foo.pm in @INC DESCRIPTION
When testing applications, often you find yourself needing to provide functionality in your test environment that would usually be provided by external modules. Rather than munging the %INC by hand to mark these external modules as loaded, so they are not attempted to be loaded by perl, this module offers you a very simple way to mark modules as loaded and/or unloaded. FUNCTIONS
$bool = mark_as_loaded( PACKAGE ); Marks the package as loaded to perl. "PACKAGE" can be a bareword or string. If the module is already loaded, "mark_as_loaded" will carp about this and tell you from where the "PACKAGE" has been loaded already. $bool = mark_as_unloaded( PACKAGE ); Marks the package as unloaded to perl, which is the exact opposite of "mark_as_loaded". "PACKAGE" can be a bareword or string. If the module is already unloaded, "mark_as_unloaded" will carp about this and tell you the "PACKAGE" has been unloaded already. $loc = is_loaded( PACKAGE ); "is_loaded" tells you if "PACKAGE" has been marked as loaded yet. "PACKAGE" can be a bareword or string. It returns falls if "PACKAGE" has not been loaded yet and the location from where it is said to be loaded on success. BUG REPORTS
Please report bugs or other issues to <bug-module-loaded@rt.cpan.org<gt>. AUTHOR
This module by Jos Boumans <kane@cpan.org>. COPYRIGHT
This library is free software; you may redistribute and/or modify it under the same terms as Perl itself. perl v5.18.2 2013-11-04 Module::Loaded(3pm)

Check Out this Related Man Page

Module::Implementation(3pm)				User Contributed Perl Documentation			       Module::Implementation(3pm)

NAME
Module::Implementation - Loads one of several alternate underlying implementations for a module VERSION
version 0.06 SYNOPSIS
package Foo::Bar; use Module::Implementation; BEGIN { my $loader = Module::Implementation::build_loader_sub( implementations => [ 'XS', 'PurePerl' ], symbols => [ 'run', 'check' ], ); $loader->(); } package Consumer; # loads the first viable implementation use Foo::Bar; DESCRIPTION
This module abstracts out the process of choosing one of several underlying implementations for a module. This can be used to provide XS and pure Perl implementations of a module, or it could be used to load an implementation for a given OS or any other case of needing to provide multiple implementations. This module is only useful when you know all the implementations ahead of time. If you want to load arbitrary implementations then you probably want something like a plugin system, not this module. API
This module provides two subroutines, neither of which are exported. Module::Implementation::<build_loader_sub(...) This subroutine takes the following arguments. o implementations This should be an array reference of implementation names. Each name should correspond to a module in the caller's namespace. In other words, using the example in the "SYNOPSIS", this module will look for the "Foo::Bar::XS" and "Foo::Bar::PurePerl" modules will be installed This argument is required. o symbols A list of symbols to copy from the implementation package to the calling package. These can be prefixed with a variable type: "$", "@", "%", "&", or "*)". If no prefix is given, the symbol is assumed to be a subroutine. This argument is optional. This subroutine returns the implementation loader as a sub reference. It is up to you to call this loader sub in your code. I recommend that you do not call this loader in an "import()" sub. If a caller explicitly requests no imports, your "import()" sub will not be run at all, which can cause weird breakage. Module::Implementation::implementation_for($package) Given a package name, this subroutine returns the implementation that was loaded for the package. This is not a full package name, just the suffix that identifies the implementation. For the "SYNOPSIS" example, this subroutine would be called as "Module::Implementation::implementation_for('Foo::Bar')", and it would return "XS" or "PurePerl". HOW THE IMPLEMENTATION LOADER WORKS
The implementation loader works like this ... First, it checks for an %ENV var specifying the implementation to load. The env var is based on the package name which loads the implementations. The "::" package separator is replaced with "_", and made entirely upper-case. Finally, we append "_IMPLEMENTATION" to this name. So in our "SYNOPSIS" example, the corresponding %ENV key would be "FOO_BAR_IMPLEMENTATION". If this is set, then the loader will only try to load this one implementation. If the env var requests an implementation which doesn't match one of the implementations specified when the loader was created, an error is thrown. If this one implementation fails to load then loader throws an error. This is useful for testing. You can request a specific implementation in a test file by writing something like this: BEGIN { $ENV{FOO_BAR_IMPLEMENTATION} = 'XS' } use Foo::Bar; If the environment variable is not set, then the loader simply tries the implementations originally passed to "Module::Implementation". The implementations are tried in the order in which they were originally passed. The loader will use the first implementation that loads without an error. It will copy any requested symbols from this implementation. If none of the implementations can be loaded, then the loader throws an exception. The loader returns the name of the package it loaded. AUTHOR
Dave Rolsky <autarch@urth.org> COPYRIGHT AND LICENSE
This software is Copyright (c) 2012 by Dave Rolsky. This is free software, licensed under: The Artistic License 2.0 (GPL Compatible) perl v5.14.2 2012-02-12 Module::Implementation(3pm)
Man Page