Basic HTML version of Foils prepared March 30 97

Foil 76 Processing the Environment %ENV
(Chapter 15 of Llama Book)

From PERL4 Tutorial for CPS616 Computational Science for Information Age Course CPS616 -- February 1995. by Geoffrey C. Fox


1 %ENV is set as the shell environment which the Perl program was invoked
2 Any UNIX processes invoked by system, fork, backquotes, open inherits an environment specified by %ENV at invocation of child process.
3 One can change %ENV in the same way as any associative array
4 %ENVIN = %ENV ; $oldpath = $ENV{"PATH"}; # saves input environment
5 $ENV{"PATH"} = $oldpath . ":/web/cgi"; # resets PATH to include an extra directory to be used by child process -- later we run
6 %ENV=%ENVIN; # Restores original environment
7 One can see what has been passed in %ENV by using Perl keys function
8 foreach $key (sort keys %ENV ) {
  • print "$key=$ENV{$key}\n"; # both $key $ENV{} are interpolated
9 }

in Table To:


© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sat Sep 6 1997