in reply to Setting env vars in current process

Works fine on Win2K

C:\>type test.pl # grab the first ENV var name we find for ( keys %ENV ) { $key = $_; last; } # reset ENV var print "Resetting $key, was $ENV{$key}\n"; $ENV{$key} = 'new value'; # fork my $pid = fork(); # confess print $pid ? "Parent has $key:$ENV{$key}\n" : "Child has $key:$ENV{$ke +y}\n"; C:\>perl test.pl Resetting PROMPT, was $P$G Parent has PROMPT:new value Child has PROMPT:new value C:\>

And on Redhat 7.3

[root@www root]# cat test.pl # grab the first ENV var name we find for ( keys %ENV ) { $key = $_; last; } # reset ENV var print "Resetting $key, was $ENV{$key}\n"; $ENV{$key} = 'new value'; # fork my $pid = fork(); # confess print $pid ? "Parent has $key:$ENV{$key}\n" : "Child has $key:$ENV{$ke +y}\n"; [root@www root]# perl test.pl Resetting _, was /usr/bin/perl Parent has _:new value Child has _:new value [root@www root]#

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Replies are listed 'Best First'.
Re: Re: Setting env vars in current process
by ruscoekm (Monk) on Feb 11, 2003 at 19:27 UTC
    Hmm, thanks. Your test works fine for me also. I think there must be another problem. Basically, the LD_LIBRARY_PATH of the parent shell points at libxml (C library) v2.4.22, whereas my Perl program uses a Lib::XML which only works with libxml v2.4.24 and above. So, in my Perl program, I set LD_LIBRARY_PATH to libxml v2.4.24 in a BEGIN block. However, this does not seem to be having the desired effect. Maybe I am missing something... Cheers Kevin
        Ah, many thanks for that. (Worries about the loader caching values did very faintly cross my mind - obviously much too faintly :-) I will read all the material and sort out the best approach in my case.

        Thanks again. Kevin

      It might be too late. The loader that loaded perl is probably the same loader that's loading your shared libraries. It has already initialized and is no longer looking for that environment variable. You probably have to set the variable before invoking perl.

      --- print map { my ($m)=1<<hex($_)&11?' ':''; $m.=substr('AHJPacehklnorstu',hex($_),1) } split //,'2fde0abe76c36c914586c';