Why is a tied %::ENV hash not passed to child processes?

David R. Waddell dave.waddell at mci.com
Fri May 2 17:53:57 CDT 2003


Hi,
Missed ya'll at the lunch yesterday. I have a question I was
hoping to pose at the lunch:

Instead of having ksh wrappers to perl rsh and cron scripts to provide
them with an environment, I have been experimenting with
using tied hashes. A tied %::ENV hash won't work. I was wondering
if anyone knows why. You can tie the DB files to a different hash
and copy the values over to get it to work.

This doesn't work (child_process doesn't get the %ENV):

#!/usr/local/bin/perl
use NDBM_File;
tie(%::ENV,'NDBM_File','/home/gkancir/bin/Infra_1_3_ENV',0x2|0x100,0666);
system "child_process";

This does work:

#!/usr/local/bin/perl
use NDBM_File;
tie(%MY_ENV,'NDBM_File','/home/gkancir/bin/Infra_1_3_ENV',0x2|0x100,0666);
while(($key,$value) = each %MY_ENV){
         $ENV{$key} = $value;
         print $key,"=",$value,"\n";
}
untie %MY_ENV;
system "child_process";  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/archives/pikes-peak-pm/attachments/20030502/4733ae50/attachment.htm


More information about the Pikes-peak-pm mailing list