Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!mit-eddie!uw-beaver!fluke!dcd From: dcd@tc.fluke.COM (David Dyck) Newsgroups: comp.lang.perl Subject: %ENV vs. exported environment. Keywords: %ENV environment bug question Message-ID: <1990Jul7.060454.12400@tc.fluke.COM> Date: 7 Jul 90 06:04:54 GMT Organization: John Fluke Mfg. Co., Inc., Everett, WA Lines: 80 I have been having unexpected results with %ENV. Has anyone else noticed that undef %ENV, will undefine %ENV in the perl environment, but it doesn't effect the exported environment (to child system processes). Adding new values to %ENV will export the new elements to sub processes, but the old 'undef'ed values are still exported also. deleting specific values from %ENV seems to be the same as setting that variable to "", instead of removing it from the environment. Only reset clears the exported environment. Is this by design? If so, why? I invoked the following script with: env - F=1 G=2 /usr/local/perl p1 -- cut here for script p1 -- #!/usr/local/perl $| = 1; &printenv; print "undef \%ENV;\n"; undef %ENV; &printenv; $ENV{'TERM'} = 'sun'; &printenv; for $key (keys %ENV) { print "undef \$ENV\{$key\};\n"; undef $ENV{$key}; } &printenv; print "reset 'E';\n"; reset 'E'; &printenv; sub printenv { &printperlenv; &printexportenv; } sub printperlenv { local ($key, $value); print " -- perl %ENV --\n"; while (($key,$value) = each %ENV) { print "$key=$value\n"; } # print " --\n"; } sub printexportenv { print " -- exported environment --\n"; system "/bin/env"; print " --\n"; } -- cut here David Dyck Domain: dcd@tc.fluke.COM Voice: +1 206 356 5807 UUCP: {uunet,uw-beaver,decwrl,microsof,sun}!fluke!dcd Snail: John Fluke Mfg. Co. / P.O. Box 9090 / Everett WA 98206-9090 / USA