in reply to scripts in relocatable perl

As I can actually assume that there is a system perl installed (at least for now) I came up with this solution:
#!/usr/bin/perl if (not $ENV{PORTABLE_XL_PERL}) { require FindBin; local $ENV{PORTABLE_XL_PERL} = 1; local $ENV{PERL5LIB} = ''; local $ENV{PERLLIB} = ''; exec("$FindBin::Bin/perl", $0, @ARGV); } print $^X;
At first sight it seems to work though I still have to find out how to make this the beginning of all the scripts.

Replies are listed 'Best First'.
Re^2: scripts in relocatable perl
by Corion (Patriarch) on Jun 28, 2009 at 13:02 UTC

    Copy this file into your Perl core lib directory:

    package CORE::Relocatable; sub import { return if $^O eq 'MSWin32' # or whatever check you deem necessary if (not $ENV{PORTABLE_XL_PERL}) { require FindBin; local $ENV{PORTABLE_XL_PERL} = 1; local $ENV{PERL5LIB} = ''; local $ENV{PERLLIB} = ''; exec("$FindBin::Bin/perl", $0, @ARGV); } } 1

    ... and have all your scripts

    use CORE::Relocatable;

    Duh - I don't know whether a relocated Perl on Unix will know where its site/lib directory is, so this might still be a nonstarter :-(