Clone or Install the Perl modules from one machine to another

Developers or system integrators install lot of Perl modules on their machines when they wanted to try with some applications or modules or APIs. But when they wanted to use the same installed modules to some other servers/machines they need to do the same exercise again on the other machines.

CPAN shell has an inbuilt feature to deal with this scenario.

perl -MCPAN -e "autobundle"

This will create a bundle file which will contain all installed modules available in the path of @INC


Now copy that bundle file to any machine and run the below command to get all those modules available in the old machine.

perl -MCPAN -e 'install Bundle::Snapshot_2015_04_16_01'

Quick Reference- Perl one liners

#search for a pattern in a file just like Linux grep command
$perl -ne ‘print if /findword/;’

#search and replace a pattern in a file and print the modified contents on the screen
$perl -pe ‘s/findword/replaceword/g;’

#search and replace a pattern in a file. Original files are backed up in .bak extension. This is one of the most powerful command if you want to do operations on large set of files in a directory.
$perl -pi.bak -e ‘s/findword/replaceword/’

#see the encode and decode characters of URLs
$perl -MURI::Escape -le ‘$var=qq(userid,;); print uri_escape($var);’
$perl -MURI::Escape -le ‘$var=qq(userid%2C%3B); print uri_unescape($var);’