.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Devel::Hide 3pm" .TH Devel::Hide 3pm "2020-02-21" "perl v5.30.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Devel::Hide \- Forces the unavailability of specified Perl modules (for testing) .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& # 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 \*(Aquse Foo::Bar\*(Aq; \& } \& # but this will load \& use Foo::Bar; .Ve .PP Other common usage patterns: .PP .Vb 2 \& $ perl \-MDevel::Hide=Module::ToHide Makefile.PL \& $ perl \-MDevel::Hide=Module::ToHide,Test::Pod Makefile.PL \& \& $ PERL5OPT=\-MDevel::Hide \& $ DEVEL_HIDE_PM=\*(AqModule::ToHide Test::Pod\*(Aq \& $ export PERL5OPT DEVEL_HIDE_PM \& $ perl Makefile.PL .Ve .SH "COMPATIBILITY" .IX Header "COMPATIBILITY" .IP "global hiding" 4 .IX Item "global hiding" At some point global hiding may \fBgo away\fR and only lexical hiding be supported. At that point support for perl versions below 5.10 will be dropped. There will be at least a two year deprecation cycle before that happens. .Sp You are strongly encouraged to only use lexical hiding and to update existing code. .IP "perl 5.6" 4 .IX Item "perl 5.6" Support will be dropped at some point after 2022\-01\-01 with no further warning. This is because bugs in older perls prevent some code improvements. See commit dd27e50 in the repository if you care to know what those are. .SH "DESCRIPTION" .IX Header "DESCRIPTION" Given a list of Perl modules/filenames, this module makes \&\f(CW\*(C`require\*(C'\fR and \f(CW\*(C`use\*(C'\fR statements fail (no matter the specified files/modules are installed or not). .PP They \fIdie\fR with a message like: .PP .Vb 1 \& Can\*(Aqt locate Module/ToHide.pm in @INC (hidden) .Ve .PP The original intent of this module is to allow Perl developers to test for alternative behavior when some modules are not available. In a Perl installation, where many modules are already installed, there is a chance to screw things up because you take for granted things that may not be there in other machines. .PP For example, to test if your distribution does the right thing when a module is missing, you can do .PP .Vb 1 \& perl \-MDevel::Hide=Test::Pod Makefile.PL .Ve .PP forcing \f(CW\*(C`Test::Pod\*(C'\fR to not be found (whether it is installed or not). .PP 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, \f(CW\*(C`XML::Simple\*(C'\fR needs a parser module and may use \&\f(CW\*(C`XML::Parser\*(C'\fR or \f(CW\*(C`XML::SAX\*(C'\fR (preferring the latter). If you have both of them installed, it will always try \f(CW\*(C`XML::SAX\*(C'\fR. But you can say: .PP .Vb 1 \& perl \-MDevel::Hide=XML::SAX script_which_uses_xml_simple.pl .Ve .PP \&\s-1NOTE.\s0 This module does not use Carp. As said before, denial \fIdies\fR. .PP This module is pretty trivial. It uses a code reference in \f(CW@INC\fR 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. .PP There are three alternative ways to include modules in the hidden list: .IP "\fBimport()\fR" 4 .IX Item "import()" this is probably the most commonly used method, called automagically when you do this: .Sp .Vb 1 \& use Devel::Hide qw(Foo Bar::Baz); .Ve .Sp or .Sp .Vb 1 \& perl \-MDevel::Hide=... .Ve .ie n .IP "setting @Devel::Hide::HIDDEN" 4 .el .IP "setting \f(CW@Devel::Hide::HIDDEN\fR" 4 .IX Item "setting @Devel::Hide::HIDDEN" .PD 0 .IP "environment variable \s-1DEVEL_HIDE_PM\s0" 4 .IX Item "environment variable DEVEL_HIDE_PM" .PD both of these two only support 'global' hiding, whereas \f(CW\*(C`import()\*(C'\fR supports lexical hiding as well. .PP Optionally, you can provide some arguments *before* the list of modules: .IP "\-from:children" 4 .IX Item "-from:children" propagate the list of hidden modules to your process' child processes. This works by populating \&\f(CW\*(C`PERL5OPT\*(C'\fR, and is incompatible with Taint mode, as explained in perlrun. Of course, this is unnecessary if your child processes are just forks of the current one. .IP "\-lexically" 4 .IX Item "-lexically" This is only available on perl 5.10.0 and later. It is a fatal error to try to use it on an older perl. .Sp Everything following this will only have effect until the end of the current scope. Yes, that includes \f(CW\*(C`\-quiet\*(C'\fR. .IP "\-quiet" 4 .IX Item "-quiet" suppresses diagnostic output. You will still get told about errors. This is passed to child processes if \-from:children is in effect. .SH "CAVEATS" .IX Header "CAVEATS" There is some interaction between \f(CW\*(C`lib\*(C'\fR and this module .PP .Vb 2 \& use Devel::Hide qw(Module/ToHide.pm); \& use lib qw(my_lib); .Ve .PP In this case, 'my_lib' enters the include path before the Devel::Hide hook and if \fIModule/ToHide.pm\fR is found in 'my_lib', it succeeds. More generally, any code that adds anything to the front of the \f(CW@INC\fR list after Devel::Hide is loaded will have this effect. .PP Also for modules that were loaded before Devel::Hide, \&\f(CW\*(C`require\*(C'\fR and \f(CW\*(C`use\*(C'\fR succeeds. .PP Since 0.0005, Devel::Hide warns about modules already loaded. .PP .Vb 2 \& $ perl \-MDevel::Hide=Devel::Hide \-e \*(Aq\*(Aq \& Devel::Hide: Too late to hide Devel/Hide.pm .Ve .SH "EXPORTS" .IX Header "EXPORTS" Nothing is exported. .SH "ENVIRONMENT VARIABLES" .IX Header "ENVIRONMENT VARIABLES" \&\s-1DEVEL_HIDE_PM\s0 \- if defined, the list of modules is added to the list of hidden modules .PP \&\s-1DEVEL_HIDE_VERBOSE\s0 \- on by default. If off, suppresses the initial message which shows the list of hidden modules in effect .PP \&\s-1PERL5OPT\s0 \- used if you specify '\-from:children' .SH "SEE ALSO" .IX Header "SEE ALSO" \&\*(L"perldoc \-f require\*(R" .PP Test::Without::Module .SH "BUGS" .IX Header "BUGS" .IP "bug" 4 .IX Item "bug" \&\f(CW\*(C`\-from:children\*(C'\fR and \f(CW\*(C`\-lexically\*(C'\fR don't like each other. Anything hidden lexically may be hidden from all child processes without regard for scope. Don't use them together. .PP Please report any other bugs you find via \s-1CPAN RT\s0 . .SH "AUTHORS" .IX Header "AUTHORS" Adriano R. Ferreira, .PP with contributions from David Cantrell .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright (C) 2005\-2007, 2018 by Adriano R. Ferreira .PP Some parts copyright (C) 2020 by David Cantrell .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.