25 Jan 2014 02:46:02 UTC
- Distribution: lib-xi
- Module version: 1.03
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (1)
- Testers (697 / 0 / 0)
- KwaliteeBus factor: 1
- License: perl_5
- Perl: v5.8.1
- Download (12.25KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version++ed by:
- Fuji Goro
- Ben Booth
- SEE ALSO
- LICENSE AND COPYRIGHT
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::xiis 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
cpanm(1)and tell it to the interpreter.
If $install_dir is specified, it is used as the install directory as
cpanm --local-lib $install_dir, adding
@INCNote 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.pmto install modules; the difference is that
cpanm -l) and has little overhead.
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
@INChook specification details
Fuji, Goro (gfx) <email@example.com>
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.
|s||Focus search bar|
|?||Bring up this help dialog|
|g p||Go to pull requests|
|g i||go to github issues (only if github is preferred repository)|
|g a||Go to author|
|g c||Go to changes|
|g i||Go to issues|
|g d||Go to dist|
|g r||Go to repository/SCM|
|g s||Go to source|
|g b||Go to file browse|