I can’t read Perl and have barely any knowledge of Perl, but it’s part of my system and sometimes I want to try out some Perl projects, but the dependencies always a mess for me because I don’t know how to cleanly remove the installed depending modules after the tryout.
This note was created primarily for how I could uninstall modules. This is not a note for coding, nor the Perl core itself. There might be mistakes in this note.
Contents
1 Modules
1.1 Installation methods
1.1.1 Build.PL
perl Build.PL # for testing ./Build test # dry-running ./Build fakeinstall --destdir=$HOME/.local --install_base=. # installing ./Build install --destdir=$HOME/.local --install_base=. # uninstalling ./Build uninstall --destdir=$HOME/.local --install_base=.
This is how traditionally done, but there likely is no uninstall option.
1.1.2 CPAN managers
They may require proper environment variables to be set for local installation:
export PERL_MB_OPT=$HOME/.local # Module::Build export PERL_MM_OPT=$HOME/.local # ExtUtils::MakeMaker export PERL5LIB=$PERL_MB_OPT/lib/perl5:$PERL5LIB export PATH=$PERL_MB_OPT/bin:$PATH
Use perl -V to confirm.
1.1.2.1 cpan
# -t testin / -T no testing
# -i installing
# -I load local::lib
cpan -Iit Module::Name
There is no uninstallation as far as I know. local::lib is for creating module with PERL5LIB environment variable.
1.1.2.2 cpanm (Best option)
# installing # -n --notest cpanm [-l|--local-lib <path>] <source> # uninstalling cpanm -l $PERL_MB_OPT -U <source>
You can give cpanm (App::cpanminus) a tarball, a module name, a Git link, and some others. It will eat everything, probably even your cat.
1.2 PERL5LIB environment variable
I don’t know how exactly, but the paths in PERL5LIB will be inserted at top of @INC and Perl will look at those places first when searching for loading a module.
In conjunction with local::lib, PERL_MB_OPT, PERL_MM_OPT, and managers, they can be the place to install requested modules. As long as PERL5LIB is set consistently with PERL_*_OPT, the depending Perl script should run without dependency issues.
It’s sort of equivalent to Go’s GOPATH, except Go has a simple and uncomplicated case.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.