[sf-perl] Setting LD_LIBRARY_PATH

Joe Brenner doom at kzsu.stanford.edu
Fri Jul 6 12:10:17 PDT 2007


Loo, Peter # PHX <Peter.Loo at source.wolterskluwer.com> wrote:

> I do have one question though.  If I was to have a Perl program that
> sets $ENV{LD_LIBRARY_PATH} = 'some value'; then spawning of another Perl
> program from within it using system(), will the spawned Perl program
> inherit the set environment variable?

The second program inherits the environment settings
of the first. 

It's easy enough to check:

===
#!/usr/bin/perl
# perl_env_invoke_1

use warnings;
use strict;
$|=1;

$ENV{ NASTY_HACK } = 'Hello, whirled!';
system( "perl_env_invoke_2" );

===
#!/usr/bin/perl
# perl_env_invoke_2

use warnings;
use strict;
$|=1;

if( $ENV{ NASTY_HACK } ) {
  print $ENV{ NASTY_HACK }, "\n";
} else {
  print "envar NASTY_HACK not found\n";
}
===

perl_env_invoke_2
envar NASTY_HACK not found

perl_env_invoke_1
Hello, whirled!




More information about the SanFrancisco-pm mailing list