package local::lib;
{ package Foo; sub foo { -$_[1] } sub bar { $_[1]+2 } sub baz { $_[1]+3 } } my $foo = bless({}, 'Foo'); Test::More::ok($foo->${pipeline qw(foo bar baz)}(10) == -15);
my $c = 'local::lib';
is($c->resolve_empty_path, '~/perl5'); is($c->resolve_empty_path('foo'), 'foo');
local *File::Spec::rel2abs = sub { shift; 'FOO'.shift; }; is($c->resolve_relative_path('bar'),'FOObar');
File::Path::rmtree('t/var/splat');
$c->ensure_dir_structure_for('t/var/splat');
ok(-d 't/var/splat');
ok(-f 't/var/splat/.modulebuildrc');
NAME
local::lib - create and use a local lib/ for perl modules with PERL5LIB
SYNOPSIS
In code -
use local::lib; # sets up a local lib at ~/perl5
use local::lib '~/foo'; # same, but ~/foo
From the shell -
$ perl -Mlocal::lib
export MODULEBUILDRC=/home/username/perl/.modulebuildrc
export PERL_MM_OPT='INSTALL_BASE=/home/username/perl'
export PERL5LIB='/home/username/perl/lib/perl5:/home/username/perl/lib/perl5/i386-linux'
export PATH="/home/username/perl/bin:$PATH"
To bootstrap if you don't have local::lib itself installed -
$ perl -MCPAN -eshell # you only need to do this if you don't have a ~/.cpan
cpan> exit
<download local::lib tarball from CPAN, unpack and cd into dir>
$ perl Makefile.PL --bootstrap
$ make test && make install
$ echo 'eval $(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)' >>~/.bashrc
You can also pass --boostrap=~/foo to get a different location (adjust the bashrc line appropriately)
LIMITATIONS
No support for non-bourne shells.
Bootstrap is a hack and will use CPAN.pm for ExtUtils::MakeMaker even if you have CPANPLUS installed.
Kills any existing PERL5LIB, PERL_MM_OPT or MODULEBUILDRC.
Should probably auto-fixup CPAN config if not already done.
Patches very much welcome for any of the above.
AUTHOR
Matt S Trout <mst@shadowcat.co.uk> http://www.shadowcat.co.uk/
LICENSE
This library is free software under the same license as perl itself