Basic HTML version of Foils prepared Sept 20 97

Foil 70 Processing the Environment %ENV

From Tutorial on PERL Computational Science for Information Age Course CPS616 -- Sept 20 97. by Geoffrey C. Fox,Nancy McCracken,Tom Scavo


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



© 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 Sun Sep 21 1997