Devel::Hide(3pm)
π Devel::Hide β the "bestie, pretend that module does not exist" manual π
okay so real talk, this is Devel::Hide, part of the User Contributed Perl Documentation. It forces specified Perl modules to be unavailable, which is iconic for testing. Sit down, grab a boba, let's go π§β¨
β¨ NAME β¨
Devel::Hide β Forces the unavailability of specified Perl modules (for testing) π«Ά
πΈ SYNOPSIS πΈ
# hide modules globally, across the entire process
use Devel::Hide qw(Module/ToHide.pm);
require Module::ToHide; # fails
use Devel::Hide qw(Test::Pod Test::Pod::Coverage);
require Test::More; # ok
use Test::Pod 1.18; # fails
# hide modules lexically
{
use Devel::Hide qw(-lexically Foo::Bar);
# this will fail to load
eval 'use Foo::Bar';
}
# but this will load
use Foo::Bar;
Other common usage patterns, because bestie we love a shortcut:
$ perl -MDevel::Hide=Module::ToHide Makefile.PL
$ perl -MDevel::Hide=Module::ToHide,Test::Pod Makefile.PL
$ PERL5OPT=-MDevel::Hide
$ DEVEL_HIDE_PM='Module::ToHide Test::Pod'
$ export PERL5OPT DEVEL_HIDE_PM
$ perl Makefile.PL
π COMPATIBILITY π
global hiding
so π at some point global hiding may justβ¦ go away, and only lexical hiding</> be supported. And when that happens? Support for perl versions below 5.10 gets dropped too. But calm down bestie, there will be at least a two year deprecation cycle before that happens.
You are strongly encouraged to only use lexical hiding and to update existing code. fr fr, do it now, future you will thank you π«Ά
perl 5.6
Perl version 5.6 is no longer supported. The last version of this module to support perl 5.6 was 0.0015, and 5.6 has been deprecated since 0.0012. Why? Because bugs in older perls prevent some code improvements. See commit dd27e50 in the repository if you care to know what those are π
π¦ DESCRIPTION π¦
Give this module a list of Perl modules/filenames and it makes require and use statements fail β no matter whether the specified files/modules are actually installed or not. The audacity, the power π
They die with a message like:
Can't locate Module/ToHide.pm in @INC (hidden)
The original intent of this module is to let Perl developers test alternative behavior when some modules are not available. Because like, in a Perl installation where many modules are already installed, there is a chance to screw things up π« β you take for granted things that may not be there on other machines. Main character energy on your laptop, chaos on someone else's.
For example, to test if your distribution does the right thing when a module is missing, you can do:
perl -MDevel::Hide=Test::Pod Makefile.PL
forcing Test::Pod to not be found (whether it is installed or not). Slay.
Another use case is to force a module which can choose between two requisites to use the one which is not the default. For example, XML::Simple needs a parser module and may use XML::Parser or XML::SAX (preferring the latter). If you have both of them installed, it will always try XML::SAX. But you can say:
perl -MDevel::Hide=XML::SAX script_which_uses_xml_simple.pl
NOTE. This module does not use Carp. As said before, denial dies. π
This module is pretty trivial ngl. It uses a code reference in @INC to get rid of specific modules during require β denying they can be successfully loaded and stopping the search before they have a chance to be found. Iconic behavior, honestly.
There are three alternative ways to include modules in the hidden list:
import()β this is probably the most commonly used method, called automagically when you do this:
use Devel::Hide qw(Foo Bar::Baz);
or
perl -MDevel::Hide=...
- setting
@Devel::Hide::HIDDEN - environment variable
DEVEL_HIDE_PM
β¨ both of these two only support 'global' hiding, whereas import() supports lexical hiding as well.
Optionally, you can provide some arguments before the list of modules:
-from:childrenβ propagate the list of hidden modules to your process' child processes. This works by populatingPERL5OPT, and is incompatible with Taint mode, as explained inperlrun. Of course, this is unnecessary if your child processes are just forks of the current one.-lexicallyβ This is only available on perl5.10.0and later. It is a fatal error to try to use it on an older perl.
Everything following this will only have effect until the end of the current scope. Yes, that includes -quiet. The scope is the vibe, periodt.
-quietβ suppresses diagnostic output. You will still get told about errors. This is passed to child processes if-from:childrenis in effect.
π CAVEATS π
There is some interaction between lib and this module π
use Devel::Hide qw(Module/ToHide.pm);
use lib qw(my_lib);
In this case, my_lib enters the include path before the Devel::Hide hook and if Module/ToHide.pm is found in my_lib, it succeeds. More generally, any code that adds anything to the front of the @INC list after Devel::Hide is loaded will have this effect. Rude, honestly.
Also, for modules that were loaded before Devel::Hide, require and use succeed. Too late bestie, they're already here π
Since 0.0005, Devel::Hide warns about modules already loaded:
$ perl -MDevel::Hide=Devel::Hide -e ''
Devel::Hide: Too late to hide Devel/Hide.pm
π EXPORTS π
Nothing is exported. That's it, that's the section. Nothing. Zero. Nada. π
π ENVIRONMENT VARIABLES π
DEVEL_HIDE_PMβ if defined, the list of modules is added to the list of hidden modules.DEVEL_HIDE_VERBOSEβ on by default. If off, suppresses the initial message which shows the list of hidden modules in effect.PERL5OPTβ used if you specify-from:children.
β SEE ALSO β
perldoc -f requireTest::Without::Module
π BUGS π
- bug
-from:childrenand-lexicallydon't like each other. Anything hidden lexically may be hidden from all child processes without regard for scope. Don't use them together. Justβ¦ don't. π
Please report any other bugs you find via CPAN RT <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Devel-Hide>.
π AUTHORS π
- Adriano R. Ferreira, <ferreira@cpan.org>
- with contributions from David Cantrell <dcantrell@cpan.org>
π COPYRIGHT AND LICENSE π
Copyright (C) 2005-2007, 2018 by Adriano R. Ferreira
Some parts copyright (C) 2020 by David Cantrell
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
okay and that's the whole page bestie, you ate that π«Ά this was Devel::Hide(3pm), shipped with perl v5.40.1, dated 2026-01-02. go hide a module, stay hydrated, love u πβ¨
π¦ where this page comes from
- ubuntu resolute: libdevel-hide-perl 0.0016-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libdevel-hide-perl 0.0016-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms