How to set 'env'-var in perl 
Author Message
 How to set 'env'-var in perl

I try to create a new enviroment variable in a perl-script.
With:
  $ENV[foo] = $gaga;
it works fine so far, but who to export it for use after exit of the
script ?

Rolf Hatt
HALLO Internet AG
Switzerland



Tue, 03 Nov 1998 03:00:00 GMT  
 How to set 'env'-var in perl

: I try to create a new enviroment variable in a perl-script.
: With:
:   $ENV[foo] = $gaga;
        ^   ^             ???
: it works fine so far, but who to export it for use after exit of the
: script ?

from the fine Perl FAQ:

5.24) 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?

    In the strictest sense, it "can't" be done.  However, there is special
    shell magic which may allow you to do it.  I suggest checking out
    comp.unix.shell and reading the comp.unix.questions FAQ.

    When perl is started, you are creating a child process.  Due to the way
    the Unix system is designed, children cannot permanently affect their
    parent shells.

    When a child process is created, it inherits a copy of its parents
    environment (variables, current directory, etc).  When the child
    changes this environment, it is changing the copy and not the original,
    so the parent isn't affected.

    If you must change the parent from within a perl script, you could try
    having it write out a shell script or a C-shell script and then using
    ". script" or "source script" (sh, Csh, respectively)

--
  Tad McClellan,      Logistics Specialist (IETMs and SGML guy)

The "Battle of the Sexes" is perpetuated by fraternizing with the enemy.



Tue, 03 Nov 1998 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Setting $ENV{'PATH'}

2. QUESTION: SETTING $ENV{'REQUEST_METHOD'} to POST

3. Expand ENV var within another ENV var

4. HELP: CGI can't find PERL5LIB env var

5. Why can't I set env variable in Perl (NT)

6. ??? set a local env var in perl script

7. Beginner's question : how to set path and env

8. Setting $ENV{LD_LIBRARY_PATH} doesn't work

9. no database driver specified and DBI_DSN env var not set

10. Win32 perl how to do system(set var= $var)

11. '$var =~ ///g' equals '$var =~ m// divided by g'

12. $ENV{'AUTH_TYPE'} and $ENV{'REMOTE_USER'}

 

 
Powered by phpBB® Forum Software