in reply to Re: DynaLoader and LD_LIBRARY_PATH
in thread DynaLoader and LD_LIBRARY_PATH

I did try it with a BEGIN block. I took the BEGIN block out in my post. It did not make it work.

Your alternate idea would be something like this?

BEGIN { unless ($ENV{PATH} =~ m#/foo/bin#) { $ENV{PATH} = "/foo/bin:/bar/bin:$ENV{PATH}"; $ENV{LD_LIBRARY_PATH} = "/foo/bin:/bar/bin:$ENV{LD_LIBRARY_PATH}"; $ENV{PERL5LIB} = "/foo/lib:$ENV{PERL5LIB}"; exec("$0 @ARGV"); exit; } } use foo;
? -Imran

Replies are listed 'Best First'.
Re^3: DynaLoader and LD_LIBRARY_PATH
by Tanktalus (Canon) on Nov 10, 2005 at 18:38 UTC

    Close. The exec line would look like this:

    exec($^X, $0, @ARGV);
    And you don't need the exit line - when exec runs, it replaces the current process with the new process. The "current" process won't even exist anymore - processing continues at the beginning of the new program.