Env::C's explanation is that the glue code doesn't translate one to the other, but I'm not going to try to pick apart SWIG internals to find out why not.
Instead, my solution was to do this:
sub sync_env_settings_from_c {
my $env_string = CCode::getEnvSettings();
# in addition to grabbing changed settings, we also need
# to remove deleted settings, so we reset the %ENV
# hash. Note: do it *after* the call to getEnvSettings
# or else $env_string will be empty.
undef %ENV;
foreach my $block (split($SEPARATOR, $env_string)) {
next if (!$block); # first one's empty because I'm lazy
# each one looks like "key=value":
my ($key, $value) = split(m{=}, $block, 2);
$ENV{$key} = $value;
}
return;
}
I'm sure the efficiency is questionable, but at least it seems to be correct.
In reply to Re^2: %ENV vs C's setenv
by Corrahn
in thread %ENV vs C's setenv
by Corrahn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |