in reply to LD_LIBRARY_PATH setting

On most operating systems, $^X contains the full path to the perl executable used to run your script, so you should not need to involve env.

Your approach is the correct approach to restart your Perl script with added parameters, but you need to add one more parameter that indicates that your Perl script has restarted itself already:

BEGIN { if( ! $ENV{PDUPRE_RESTART}) { $ENV{LD_LIBRARY_PATH} = '...'; $ENV{PDUPRE_RESTART} = 1; exec $0, '--restarted', @ARGV }; }; ...

Replies are listed 'Best First'.
Re^2: LD_LIBRARY_PATH setting
by pdupre (Acolyte) on Aug 05, 2016 at 18:40 UTC

    Thank

    But it still does not work!

    it just freezes

    and finally (after a timeout?) ignores what is in the enclosure

    Patrick Dupre Universite du Littoral, FR Dunkirk

      Maybe you can print some output so you see what is happening?

      Alternatively, trace your program with truss or strace to see what system calls it makes.

      Maybe you can post a short, self-contained example of the program you're actually running so we can reproduce your problem exactly?

        #!/usr/bin/perl BEGIN { $ENV{LD_LIBRARY_PATH} = "/usr/local/gsl-1/lib" ; exec $0, '--restarted', @ARGV ; } ; require Math::GSL ; use strict; use warnings; print $ENV{LD_LIBRARY_PATH}, "\n";
        Can't load '/usr/lib/perl5/vendor_perl/auto/Math/GSL/Errno/Errno.so' +for module Math::GSL::Errno: libgsl.so.0: cannot open shared object f +ile: No such file or directory at /usr/lib/perl5/DynaLoader.pm line 1 +93. at /usr/lib/perl5/vendor_perl/Math/GSL/Errno.pm line 11. Compilation failed in require at /usr/lib/perl5/vendor_perl/Math/GSL/T +est.pm line 7. BEGIN failed--compilation aborted at /usr/lib/perl5/vendor_perl/Math/G +SL/Test.pm line 7. Compilation failed in require at /usr/lib/perl5/vendor_perl/Math/GSL.p +m line 10. BEGIN failed--compilation aborted at /usr/lib/perl5/vendor_perl/Math/G +SL.pm line 10. Compilation failed in require at ./test.pl line 10.
        Patrick Dupre Universite du Littoral, FR Dunkirk