| 1 |
.\" -*- mode: troff; coding: utf-8 -*- |
| 2 |
.\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) |
| 3 |
.\" |
| 4 |
.\" Standard preamble: |
| 5 |
.\" ======================================================================== |
| 6 |
.de Sp \" Vertical space (when we can't use .PP) |
| 7 |
.if t .sp .5v |
| 8 |
.if n .sp |
| 9 |
.. |
| 10 |
.de Vb \" Begin verbatim text |
| 11 |
.ft CW |
| 12 |
.nf |
| 13 |
.ne \\$1 |
| 14 |
.. |
| 15 |
.de Ve \" End verbatim text |
| 16 |
.ft R |
| 17 |
.fi |
| 18 |
.. |
| 19 |
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. |
| 20 |
.ie n \{\ |
| 21 |
. ds C` "" |
| 22 |
. ds C' "" |
| 23 |
'br\} |
| 24 |
.el\{\ |
| 25 |
. ds C` |
| 26 |
. ds C' |
| 27 |
'br\} |
| 28 |
.\" |
| 29 |
.\" Escape single quotes in literal strings from groff's Unicode transform. |
| 30 |
.ie \n(.g .ds Aq \(aq |
| 31 |
.el .ds Aq ' |
| 32 |
.\" |
| 33 |
.\" If the F register is >0, we'll generate index entries on stderr for |
| 34 |
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index |
| 35 |
.\" entries marked with X<> in POD. Of course, you'll have to process the |
| 36 |
.\" output yourself in some meaningful fashion. |
| 37 |
.\" |
| 38 |
.\" Avoid warning from groff about undefined register 'F'. |
| 39 |
.de IX |
| 40 |
.. |
| 41 |
.nr rF 0 |
| 42 |
.if \n(.g .if rF .nr rF 1 |
| 43 |
.if (\n(rF:(\n(.g==0)) \{\ |
| 44 |
. if \nF \{\ |
| 45 |
. de IX |
| 46 |
. tm Index:\\$1\t\\n%\t"\\$2" |
| 47 |
.. |
| 48 |
. if !\nF==2 \{\ |
| 49 |
. nr % 0 |
| 50 |
. nr F 2 |
| 51 |
. \} |
| 52 |
. \} |
| 53 |
.\} |
| 54 |
.rr rF |
| 55 |
.\" ======================================================================== |
| 56 |
.\" |
| 57 |
.IX Title "Module::Loaded 3perl" |
| 58 |
.TH Module::Loaded 3perl 2025-11-16 "perl v5.40.1" "Perl Programmers Reference Guide" |
| 59 |
.\" For nroff, turn off justification. Always turn off hyphenation; it makes |
| 60 |
.\" way too many mistakes in technical documents. |
| 61 |
.if n .ad l |
| 62 |
.nh |
| 63 |
.SH NAME |
| 64 |
Module::Loaded \- mark modules as loaded or unloaded |
| 65 |
.SH SYNOPSIS |
| 66 |
.IX Header "SYNOPSIS" |
| 67 |
.Vb 1 |
| 68 |
\& use Module::Loaded; |
| 69 |
\& |
| 70 |
\& $bool = mark_as_loaded(\*(AqFoo\*(Aq); # Foo.pm is now marked as loaded |
| 71 |
\& $loc = is_loaded(\*(AqFoo\*(Aq); # location of Foo.pm set to the |
| 72 |
\& # loaders location |
| 73 |
\& eval "require \*(AqFoo\*(Aq"; # is now a no\-op |
| 74 |
\& |
| 75 |
\& $bool = mark_as_unloaded(\*(AqFoo\*(Aq); # Foo.pm no longer marked as loaded |
| 76 |
\& eval "require \*(AqFoo\*(Aq"; # Will try to find Foo.pm in @INC |
| 77 |
.Ve |
| 78 |
.SH DESCRIPTION |
| 79 |
.IX Header "DESCRIPTION" |
| 80 |
When testing applications, often you find yourself needing to provide |
| 81 |
functionality in your test environment that would usually be provided |
| 82 |
by external modules. Rather than munging the \f(CW%INC\fR by hand to mark |
| 83 |
these external modules as loaded, so they are not attempted to be loaded |
| 84 |
by perl, this module offers you a very simple way to mark modules as |
| 85 |
loaded and/or unloaded. |
| 86 |
.SH FUNCTIONS |
| 87 |
.IX Header "FUNCTIONS" |
| 88 |
.ie n .SS "$bool = mark_as_loaded( PACKAGE );" |
| 89 |
.el .SS "\f(CW$bool\fP = mark_as_loaded( PACKAGE );" |
| 90 |
.IX Subsection "$bool = mark_as_loaded( PACKAGE );" |
| 91 |
Marks the package as loaded to perl. \f(CW\*(C`PACKAGE\*(C'\fR can be a bareword or |
| 92 |
string. |
| 93 |
.PP |
| 94 |
If the module is already loaded, \f(CW\*(C`mark_as_loaded\*(C'\fR will carp about |
| 95 |
this and tell you from where the \f(CW\*(C`PACKAGE\*(C'\fR has been loaded already. |
| 96 |
.ie n .SS "$bool = mark_as_unloaded( PACKAGE );" |
| 97 |
.el .SS "\f(CW$bool\fP = mark_as_unloaded( PACKAGE );" |
| 98 |
.IX Subsection "$bool = mark_as_unloaded( PACKAGE );" |
| 99 |
Marks the package as unloaded to perl, which is the exact opposite |
| 100 |
of \f(CW\*(C`mark_as_loaded\*(C'\fR. \f(CW\*(C`PACKAGE\*(C'\fR can be a bareword or string. |
| 101 |
.PP |
| 102 |
If the module is already unloaded, \f(CW\*(C`mark_as_unloaded\*(C'\fR will carp about |
| 103 |
this and tell you the \f(CW\*(C`PACKAGE\*(C'\fR has been unloaded already. |
| 104 |
.ie n .SS "$loc = is_loaded( PACKAGE );" |
| 105 |
.el .SS "\f(CW$loc\fP = is_loaded( PACKAGE );" |
| 106 |
.IX Subsection "$loc = is_loaded( PACKAGE );" |
| 107 |
\&\f(CW\*(C`is_loaded\*(C'\fR tells you if \f(CW\*(C`PACKAGE\*(C'\fR has been marked as loaded yet. |
| 108 |
\&\f(CW\*(C`PACKAGE\*(C'\fR can be a bareword or string. |
| 109 |
.PP |
| 110 |
It returns falls if \f(CW\*(C`PACKAGE\*(C'\fR has not been loaded yet and the location |
| 111 |
from where it is said to be loaded on success. |
| 112 |
.SH "BUG REPORTS" |
| 113 |
.IX Header "BUG REPORTS" |
| 114 |
Please report bugs or other issues to <bug\-module\[email protected]<gt>. |
| 115 |
.SH AUTHOR |
| 116 |
.IX Header "AUTHOR" |
| 117 |
This module by Jos Boumans <[email protected]>. |
| 118 |
.SH COPYRIGHT |
| 119 |
.IX Header "COPYRIGHT" |
| 120 |
This library is free software; you may redistribute and/or modify it |
| 121 |
under the same terms as Perl itself. |