aoeuidhtn has asked for the wisdom of the Perl Monks concerning the following question:

I use Perl to run kpcli, command-line interface to Keepass: http://kpcli.sourceforge.net/. It requires several non-standard modules that can be installed from CPAN. I want to have an USB stick containing a standalone Perl interpreter for both x86 and x86_64 systems, all modules required to run kpcli and kpcli code itself. I want to carry this USB stick around in case I found myself in the situation I need to run kpcli on someone else's machine, a machine without Perl installed or a newly installed system in order to gain access to my password protected Git repository with all config files. But this question is not going to about how to achieve my goal but whether the way I did it is the best and what are the potential pitfalls. What I did is:

- I downloaded Perl source code
- I installed it to ~/perl-install on my PC
- I used ~/perl-install/bin/perl to install all modules required by kpcli using -MCPAN. They were installed to ~/perl-install directory
- I copied a whole ~/perl-install directory to my USB stick
- I plugged an USB stick to another machine and set PERL5LIB to a directory on USB stick like this:

$ export PERL5LIB=$PWD/lib/5.22.0/:$PWD/lib/site_perl/5.22.0/i686-linux:$PWD/lib/site_perl/5.22.0:$PWD/lib/5.22.0/i686-linux

- I run bin/perl kpcli from the USB stick

I compiled and copied a Perl interpreter for both x86 and x86_64 systems because there are some systems such as Slackware that cannot run x86 binaries x86_64 systems out of the box. Is it a good way?
  • Comment on Self-contained Perl installation with custom modules on USB stick for *nix systems

Replies are listed 'Best First'.
Re: Self-contained Perl installation with custom modules on USB stick for *nix systems
by i5513 (Pilgrim) on Jul 22, 2015 at 12:03 UTC
    I think it is a good way to do such task. I would use perlbrew, but it would not be a better method.
    If you have not already done, add export sentence, and PATH to some script on usb , so you have not to write it everytime
    Regards,
Re: Self-contained Perl installation with custom modules on USB stick for *nix systems
by syphilis (Archbishop) on Jul 22, 2015 at 12:14 UTC
    I copied a whole ~/perl-install directory to my USB stick

    But then:

    I compiled and copied a Perl interpreter for both x86 and x86_64 systems ...

    So there are two perls on the USB stick ?
    What is it that ensures that the correct interpreter is found ? (Or do you have 2 USB sticks - one for each perl ?)

    Is it a good way?

    I perhaps haven't got my head around the precise details of what you're doing, but the description sounds straightforward - so I would say "yes" (if it's working ok ;-)

    Cheers,
    Rob
      So there are two perls on the USB stick ?
      Yes, but in two separate directories with all dependencies inside in these directories. I just execute <DIR>/bin/perl <path/to/kpcli> by hand after setting PERL5LIB
        If you have not already done, add export sentence, and PATH to some script on usb , so you have not to write it everytime
        Sure, I am going to write a simple script to handle opening kpcli automatically.
Re: Self-contained Perl installation with custom modules on USB stick for *nix systems
by Anonymous Monk on Jul 23, 2015 at 22:18 UTC