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