Re: unsetenv in the shell



Si <smcbutler@xxxxxxxxx> wrote:

hi, i have a perl program that calls another application. this second
application uses the value of certain environment variables during its
operation. i'm having trouble with unsetting those variables during
the course of the perl script.

my (wrong) pseudo code:

$var1 = $ENV{'VAR1};
$var2 = $ENV{'VAR2'};
$var3 = $ENV{'VAR3'};

system( "unsetenv VAR1");
system( "unsetenv VAR2");
system( "unsetenv VAR3");

"Unsetting" an environment variable is in no way different from setting it.
Your case is a variation of the FAQs:
I {changed directory, modified my environment} in a perl script. How come
the change disappeared when I exited the script? How do I get my changes to
be visible?

Just do those changes in the script itself instead of in a child process
(perldoc -f delete)

jue
.



Relevant Pages

  • Re: environment variables in perl scripts
    ... Define a BEGIN block in your perl program. ... > perl script, something like: ... > environment variables are there and diag.txt shows ... > This communication is intended for the use of the ...
    (perl.dbi.users)
  • Re: unsetenv in the shell
    ... application uses the value of certain environment variables during its ... the course of the perl script. ... system("unsetenv VAR1"); ... ++ executes as a different process from the shell it was ...
    (comp.lang.perl.misc)
  • Re: How to set environment variable
    ... I am new to perl. ... I want to set environment variable in a perl script ... and want to display the contents of the environment variable in the command line after executing the script. ... can't set the environment variables from another process to the ...
    (perl.beginners)
  • Re: How to emulate this set or how to assign the result of running system "command" to a variable
    ... grab some of the environment variables that are set when the Perl script ... am confused on how to do it inside Perl. ... The return value is the exit status of the program as returned by ...
    (perl.beginners)
  • Re: unsetenv in the shell
    ... application uses the value of certain environment variables during its ... the course of the perl script. ... system("unsetenv VAR1"); ... starts a second process which then tries to execute the "unsetenv" ...
    (comp.lang.perl.misc)