dcd@tc.fluke.COM (David Dyck) (07/07/90)
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
lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (07/10/90)
In article <1990Jul7.060454.12400@tc.fluke.COM> dcd@tc.fluke.COM (David Dyck) writes: : : 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? No, it just kinda came out that way. I'd need to add a little code to make clearing %ENV work right, and I just haven't done it. The reset happens to work because there's code in there to catch it. Deleting specific values from %ENV is supposed to work (i.e. there's code there for it), but it got busted when I instituted "undef", I think. >>Todo. Larry