The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Acme::CPANModules::HidingModules - List of modules to hide other modules

VERSION

This document describes version 0.005 of Acme::CPANModules::HidingModules (from Perl distribution Acme-CPANModules-HidingModules), released on 2023-10-29.

DESCRIPTION

So you want to convince some Perl code that some modules that are actually installed, aren't? There are several ways to accomplish this, with different effects and levels of convincing. This list details them.

Why?

First of all, why would you want to do this? Almost always, the answer is: for testing purposes. For example, you want to make sure that your code can work without an optional module. Or, alternatively, you want to test how your code fails under the absence of certain modules.

Making modules not loadable

Most of the time, you just want to make certain modules not loadable. That is, making require SomeModule or use Module fail. To do this, you usually install a hook at the first element of @INC. The hook would die when it receives a request to load a module that you want to hide. Some tools that work this way include:

lib::filter family, including its thin wrapper lib::disallow. lib::filter et al supports hiding modules that you specify, as well as hiding all core modules or all non-core modules. They also support recursive allowing, i.e. you want to allow Moo and all the modules that Moo loads, and all the modules that they load, and so on.

Devel::Hide. Devel::Hide also works by installing a hook in @INC. It supports propagating the hiding to child process by setting PERL5OPT environment variable.

Test::Without::Module.

Fooling module path finders

Depending on which tool you use to find a module's path, here are some patches you can load to fool the finder.

Module::Path::Patch::Hide

Module::Path::More::Patch::Hide

Fooling module listers

Depending on which tool you use to find a module's path, here are some patches you can load to fool the lister tool.

Module::List::Patch::Hide

PERLANCAR::Module::List::Patch::Hide

Module::List::Tiny::Patch::Hide

Module::List::Wildcard::Patch::Hide

Hard-core hiding

To fool code that tries to find the module files themselves without using any module, i.e. by iterating @INC, you will need to actually (temporarily) rename the module files. App::pmhiderename and <lib::hiderename> does this.

ACME::CPANMODULES ENTRIES

lib::filter

Author: PERLANCAR

lib::disallow

Author: PERLANCAR

Devel::Hide

Author: DCANTRELL

Test::Without::Module

Author: CORION

Module::Path::Patch::Hide

Author: PERLANCAR

Module::Path::More::Patch::Hide

Author: PERLANCAR

Module::List::Patch::Hide

Author: PERLANCAR

PERLANCAR::Module::List::Patch::Hide

Author: PERLANCAR

Module::List::Tiny::Patch::Hide

Author: PERLANCAR

Module::List::Wildcard::Patch::Hide

Author: PERLANCAR

App::pmhiderename

Author: PERLANCAR

FAQ

What is an Acme::CPANModules::* module?

An Acme::CPANModules::* module, like this module, contains just a list of module names that share a common characteristics. It is a way to categorize modules and document CPAN. See Acme::CPANModules for more details.

What are ways to use this Acme::CPANModules module?

Aside from reading this Acme::CPANModules module's POD documentation, you can install all the listed modules (entries) using cpanm-cpanmodules script (from App::cpanm::cpanmodules distribution):

 % cpanm-cpanmodules -n HidingModules

Alternatively you can use the cpanmodules CLI (from App::cpanmodules distribution):

    % cpanmodules ls-entries HidingModules | cpanm -n

or Acme::CM::Get:

    % perl -MAcme::CM::Get=HidingModules -E'say $_->{module} for @{ $LIST->{entries} }' | cpanm -n

or directly:

    % perl -MAcme::CPANModules::HidingModules -E'say $_->{module} for @{ $Acme::CPANModules::HidingModules::LIST->{entries} }' | cpanm -n

This Acme::CPANModules module also helps lcpan produce a more meaningful result for lcpan related-mods command when it comes to finding related modules for the modules listed in this Acme::CPANModules module. See App::lcpan::Cmd::related_mods for more details on how "related modules" are found.

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/Acme-CPANModules-HidingModules.

SOURCE

Source repository is at https://github.com/perlancar/perl-Acme-CPANModules-HidingModules.

SEE ALSO

Acme::CPANModules - about the Acme::CPANModules namespace

cpanmodules - CLI tool to let you browse/view the lists

AUTHOR

perlancar <perlancar@cpan.org>

CONTRIBUTING

To contribute, you can send patches by email/via RT, or send pull requests on GitHub.

Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via:

 % prove -l

If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond that are considered a bug and can be reported to me.

COPYRIGHT AND LICENSE

This software is copyright (c) 2023, 2020, 2019 by perlancar <perlancar@cpan.org>.

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

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Acme-CPANModules-HidingModules

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.