1 package lib::core::only;
4 use warnings FATAL => 'all';
8 @INC = @Config{qw(privlibexp archlibexp)};
14 lib::core::only - Remove all non-core paths from @INC to avoid site/vendor dirs
18 use lib::core::only; # now @INC contains only the two core directories
20 # To get only the core directories plus the ones for the local::lib in
23 $ perl -Mlib::core::only -Mlocal::lib=~/perl5 myscript.pl
27 lib::core::only is simply a shortcut to say "please reduce my @INC to only
28 the core lib and archlib directories of this perl".
30 You might want to do this to ensure a local::lib contains only the code you
31 need, or to test an L<App::FatPacker|App::FatPacker> tree, or to avoid known
34 You might want to use this to try and install a self-contained tree of perl
35 modules. Be warned that that probably won't work (see L</CAVEATS>).
37 This module was extracted from L<local::lib|local::lib>'s --self-contained
38 feature, and contains the only part that ever worked. I apologise to anybody
39 who thought anything else did.
43 This does B<not> propagate properly across perl invocations like local::lib's
44 stuff does. It can't. It's only a module import, so it B<only affects the
45 specific perl VM instance in which you load and import() it>.
47 If you want to cascade it across invocations, you can set the PERL5OPT
48 environment variable to '-Mlib::core::only' and it'll sort of work. But be
49 aware that taint mode ignores this, so some modules' build and test code
50 probably will as well.
52 You also need to be aware that perl's command line options are not processed
53 in order - -I options take effect before -M options, so
55 perl -Mlib::core::only -Ilib
57 is unlike to do what you want - it's exactly equivalent to:
59 perl -Mlib::core::only
61 If you want to combine a core-only @INC with additional paths, you need to
62 add the additional paths using -M options and the L<lib|lib> module:
64 perl -Mlib::core::only -Mlib=lib
66 # or if you're trying to test compiled code:
68 perl -Mlib::core::only -Mblib
70 For more information on the impossibility of sanely propagating this across
71 module builds without help from the build program, see
72 L<http://www.shadowcat.co.uk/blog/matt-s-trout/tainted-love> - and for ways
73 to achieve the old --self-contained feature's results, look at
74 L<App::FatPacker|App::FatPacker>'s tree function, and at
75 L<App::cpanminus|cpanm>'s --local-lib-contained feature.
79 Matt S. Trout <mst@shadowcat.co.uk>
83 This library is free software under the same terms as perl itself.
87 (c) 2010 the lib::core::only L</AUTHOR> as specified above.