With perlbrew, you can use the lib command to create local::lib to go with perlbrew perl.
perlbrew lib create perl-5.20.2@app _reqs
Then, if all goes well, when you install the modules, you will find them in:
$HOME/.perlbrew/libs/ perl-5.20.2@app _reqs
If you do not use the perbrew lib create approach to manage your modules, then they are installed on $HOME/perl5/perlbrew/perls/perl-5.20.1/lib/site_perl/5.20.2 . Cloning any of these directories may work, but you are probably better off reinstalling all modules using the methods from the perlbrew.pl website , as XS modules should be rebuilt, etc.
If you want to reuse and track local sources, the most reliable approach is to create a local CPAN mirror to work using App::lcpan or minicpan . If you have already downloaded the source using cpanm , a quick hacker approach is to find the source files (under $HOME/.cpanm/ ) and do something like this in your shell:
% mkdir ~/cpansourcefiles % for source in ~/.cpanm/work/*/* ; do cp $source ~/cpansourcefiles ;done
You can then get cpanm to install using these sources by passing the file name as an argument instead of the module name:
% cpanm ~/cpansourcefiles/List-MoreUtils-0.406.tar.gz
or even:
% cpanm ~/cpansourcefiles/*
NB: YMMV, since it is prone to breakage and may miss some version and dependency checking that you usually get with cpanm , but itβs easier than setting up the mirror when it works.
A few other powerful tools that make deploying Perl applications reliable and reliable:
EDIT
Tools like perlbrew , pinto , carton and cpanm are a big improvement over the colorful personal collection of scripts for cpanm this. Thanks to all the developers and developers of these tools!
I do not know any functions in cpanm or perlbrew that allow you to reliably create a list of installed files and their versions. Something like:
cpanm --list_installed perlbrew list_installed_versions
or:
cpanm --export-cpanfile perlbrew list_installed_as_cpanfile
may be enjoyable.
As I noted in the commentary on the above OP, you can get useful information about installing your module from the install.json files installed by cpanm . Modules like CPAN::Meta , Module::Metadata and Distribution::Metadata can also be useful.
The suggestion to use find and jq (which was from @Ilmari Karonen see update all modules installed by local :: lib in this answer ) led to a quick unfinished hacker below. One problem / problem: sometimes install.json files remain in several places:
lib/perl5/$Config{archname}/.meta/Whatever-Mod-1.0050000/install.jsonlib/perl5/$Config{archname}/.meta/Whatever-Mod-1.0090000/install.json- ... etc.
This is most likely because these files are not always deleted when updating, reinstalling, or other PEBKAC error errors. In order to work correctly, the code below should be changed so that it notices when there are several combinations of the name and version of the install.json module, and then performs a more thorough check that the module is installed and receives its version. The script must have parameters: $dir may be @ARGV . TIMTOWTDI, volunteered, etc.
#!perl # list_installed_mods.pl # DOES NOT THOROUGHLY VERIFY CURRENT VERSION use File::Find; use JSON; use v5.16; my $dir = "$ENV{HOME}/perl5/lib/perl5"; for my $installed ( find_installed($dir) ) { say parse_install_json( $installed ); } sub find_installed { my $libdir = shift; my @files; File::Find::find ({ wanted => sub { push @files, $File::Find::name if /install\.json/i} }, $libdir ); return @files; } sub parse_install_json { my $filename = shift; my $json_text = do { open(my $json_fh, "<:encoding(UTF-8)", $filename) or die("Can't open \$filename\": $!\n"); local $/; <$json_fh> }; my $install = decode_json($json_text) ; return ( $install->{name} ,"\@", $install->{version} ) ; }