lib::xi - Installs missing modules on demand
This document describes lib::xi version 1.03.
# to install missing libaries automatically $ perl -Mlib::xi script.pl # with cpanm options $ perl -Mlib::xi=-q script.pl # to install missing libaries to extlib/ (with cpanm -l extlib) $ perl -Mlib::xi=extlib script.pl # with cpanm options $ perl -Mlib::xi=extlib,-q script.pl # with cpanm options via env $ PERL_CPANM_OPT='-l extlib -q' perl -Mlib::xi script.pl
When you execute a script found in, for example,
gist, you'll be annoyed
at missing libraries and will install those libraries by hand with a CPAN
client. We have repeated such a task, which violates the great virtue of
Laziness. Stop doing it, making computers do it!
lib::xi is a pragma to install missing libraries automatically if and only
if they are required.
The mechanism, using
@INC hook, is that when the perl interpreter cannot
find a library required, this pragma try to install it with
tell it to the interpreter.
lib::xi hook into
If $install_dir is specified, it is used as the install directory as
cpanm --local-lib $install_dir, adding
Note that $install_dir will be expanded to the absolute path based on
where the script is. That is, in the point of
use lib::xi 'extlib' is almost the same as the following code:
use FindBin; use lib "$FindBin::Bin/extlib/lib/perl5";
@cpanm_opts are passed directly to
cpanm(1). Note that if the first argument starts with
-, it is regarded as
@cpanm_opts, so you can simply omit
the $install_dir if it's not needed.
There are similar modules to
Module::AutoINC, which use
CPAN.pm to install modules; the difference
cpanm -l) and has little
Perl 5.8.1 or later.
All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT.
"require" in perlfunc for the
@INC hook specification details
Fuji, Goro (gfx) firstname.lastname@example.org
Copyright (c) 2011, Fuji, Goro (gfx). All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.