1lib::core::only(3) User Contributed Perl Documentation lib::core::only(3)
2
3
4
6 lib::core::only - Remove all non-core paths from @INC to avoid
7 site/vendor dirs
8
10 use lib::core::only; # now @INC contains only the two core directories
11
12 To get only the core directories plus the ones for the local::lib in
13 scope:
14
15 $ perl -mlocal::lib -Mlib::core::only -Mlocal::lib=~/perl5 myscript.pl
16
17 To attempt to do a self-contained build (but note this will not
18 reliably propagate into subprocesses, see the CAVEATS below):
19
20 $ PERL5OPT='-mlocal::lib -Mlib::core::only -Mlocal::lib=~/perl5' cpan
21
22 Please note that it is necessary to use "local::lib" twice for this to
23 work. First so that "lib::core::only" doesn't prevent "local::lib"
24 from loading (it's not currently in core) and then again after
25 "lib::core::only" so that the local paths are not removed.
26
28 lib::core::only is simply a shortcut to say "please reduce my @INC to
29 only the core lib and archlib (architecture-specific lib) directories
30 of this perl".
31
32 You might want to do this to ensure a local::lib contains only the code
33 you need, or to test an App::FatPacker tree, or to avoid known bad
34 vendor packages.
35
36 You might want to use this to try and install a self-contained tree of
37 perl modules. Be warned that that probably won't work (see "CAVEATS").
38
39 This module was extracted from local::lib's --self-contained feature,
40 and contains the only part that ever worked. I apologise to anybody who
41 thought anything else did.
42
44 This does not propagate properly across perl invocations like
45 local::lib's stuff does. It can't. It's only a module import, so it
46 only affects the specific perl VM instance in which you load and
47 import() it.
48
49 If you want to cascade it across invocations, you can set the PERL5OPT
50 environment variable to '-Mlib::core::only' and it'll sort of work. But
51 be aware that taint mode ignores this, so some modules' build and test
52 code probably will as well.
53
54 You also need to be aware that perl's command line options are not
55 processed in order - -I options take effect before -M options, so
56
57 perl -Mlib::core::only -Ilib
58
59 is unlike to do what you want - it's exactly equivalent to:
60
61 perl -Mlib::core::only
62
63 If you want to combine a core-only @INC with additional paths, you need
64 to add the additional paths using -M options and the lib module:
65
66 perl -Mlib::core::only -Mlib=lib
67
68 # or if you're trying to test compiled code:
69
70 perl -Mlib::core::only -Mblib
71
72 For more information on the impossibility of sanely propagating this
73 across module builds without help from the build program, see
74 <http://www.shadowcat.co.uk/blog/matt-s-trout/tainted-love> - and for
75 ways to achieve the old --self-contained feature's results, look at
76 App::FatPacker's tree function, and at App::cpanminus's
77 --local-lib-contained feature.
78
80 Matt S. Trout <mst@shadowcat.co.uk>
81
83 This library is free software under the same terms as perl itself.
84
86 (c) 2010 the lib::core::only "AUTHOR" as specified above.
87
88
89
90perl v5.34.0 2021-10-17 lib::core::only(3)